com.yqjr.framework.component.dialect.db.AbstractDialect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
framework Open API for Java
Copyright (C) https://gitee.com/wdcapp/framework
All rights reserved.
The newest version!
/**
*
*/
package com.yqjr.framework.component.dialect.db;
import com.yqjr.framework.component.dialect.Dialect;
import com.yqjr.framework.datatype.BizzException;
/**
* ClassName: AbstractDialect
* Description: 数据库方言公共方法
* Create By: admin
* Create Date: 2017年4月28日 下午2:38:32
* Modified By:
* Modified Date:
* Modified Content:
* Version: 1.0
*/
public abstract class AbstractDialect implements Dialect {
/**
* 获取count sql
*/
public String getCountSql(String sql) {
StringBuffer countSql = new StringBuffer();
countSql.append("select count(1) from ( ");
countSql.append(sql.trim());
countSql.append(" ) count_tmp");
return countSql.toString();
}
/**
* Description: 根据数据库类型获取数据库方言
* Create By: admin
* Create Date: 2017年5月3日 下午7:20:27
*
* @param dbType String
* @return Dialect
*/
public static Dialect getDialect(String dbType) {
if ("oracle".equalsIgnoreCase(dbType)) {
return new OracleDialect();
} else if ("mysql".equalsIgnoreCase(dbType)) {
return new MySQLDialect();
}
throw new BizzException("不能支持的dbType" + dbType);
}
}