Search in sources :

Example 1 with KingbaseDialect

use of org.sagacity.sqltoy.dialect.impl.KingbaseDialect in project sagacity-sqltoy by chenrenfei.

the class DialectFactory method getDialectSqlWrapper.

/**
 * @todo 根据数据库类型获取处理sql的handler
 * @param dbType
 * @return
 * @throws Exception
 */
private Dialect getDialectSqlWrapper(Integer dbType) throws Exception {
    // 从map中直接获取实例,避免重复创建和判断
    if (dialects.containsKey(dbType)) {
        return dialects.get(dbType);
    }
    // 按照市场排名作为优先顺序
    Dialect dialectSqlWrapper = null;
    switch(dbType) {
        // oracle12c(分页方式有了改变,支持identity主键策略(内部其实还是sequence模式))
        case DBType.ORACLE:
            {
                dialectSqlWrapper = new OracleDialect();
                break;
            }
        // MariaDB 在检测的时候归并到mysql,采用跟mysql一样的语法
        case DBType.MYSQL:
        case DBType.MYSQL57:
            {
                dialectSqlWrapper = new MySqlDialect();
                break;
            }
        // sqlserver2012 以后分页方式更简单
        case DBType.SQLSERVER:
            {
                dialectSqlWrapper = new SqlServerDialect();
                break;
            }
        // postgresql/greenplum
        case DBType.POSTGRESQL:
            {
                dialectSqlWrapper = new PostgreSqlDialect();
                break;
            }
        // oceanbase 数据库支持
        case DBType.OCEANBASE:
            {
                dialectSqlWrapper = new OceanBaseDialect();
                break;
            }
        // db2 10.x版本分页支持offset模式
        case DBType.DB2:
            {
                dialectSqlWrapper = new DB2Dialect();
                break;
            }
        // clickhouse 19.x 版本开始支持
        case DBType.CLICKHOUSE:
            {
                dialectSqlWrapper = new ClickHouseDialect();
                break;
            }
        // Tidb方言支持
        case DBType.TIDB:
            {
                dialectSqlWrapper = new TidbDialect();
                break;
            }
        // 华为guassdb(postgresql 为蓝本的)
        case DBType.GAUSSDB:
            {
                dialectSqlWrapper = new GuassDBDialect();
                break;
            }
        case DBType.IMPALA:
            {
                dialectSqlWrapper = new ImpalaDialect();
                break;
            }
        // dm数据库支持(以oracle为蓝本)
        case DBType.DM:
            {
                dialectSqlWrapper = new DMDialect();
                break;
            }
        // 基本支持(sqlite 本身功能就相对简单)
        case DBType.SQLITE:
            {
                dialectSqlWrapper = new SqliteDialect();
                break;
            }
        // 10g,11g
        case DBType.ORACLE11:
            {
                dialectSqlWrapper = new Oracle11gDialect();
                break;
            }
        // 北大金仓
        case DBType.KINGBASE:
            {
                dialectSqlWrapper = new KingbaseDialect();
                break;
            }
        // 如果匹配不上使用默认dialect
        default:
            dialectSqlWrapper = new DefaultDialect();
    }
    dialects.put(dbType, dialectSqlWrapper);
    return dialectSqlWrapper;
}
Also used : OceanBaseDialect(org.sagacity.sqltoy.dialect.impl.OceanBaseDialect) OracleDialect(org.sagacity.sqltoy.dialect.impl.OracleDialect) Oracle11gDialect(org.sagacity.sqltoy.dialect.impl.Oracle11gDialect) TidbDialect(org.sagacity.sqltoy.dialect.impl.TidbDialect) DefaultDialect(org.sagacity.sqltoy.dialect.impl.DefaultDialect) PostgreSqlDialect(org.sagacity.sqltoy.dialect.impl.PostgreSqlDialect) ClickHouseDialect(org.sagacity.sqltoy.dialect.impl.ClickHouseDialect) KingbaseDialect(org.sagacity.sqltoy.dialect.impl.KingbaseDialect) SqlServerDialect(org.sagacity.sqltoy.dialect.impl.SqlServerDialect) MySqlDialect(org.sagacity.sqltoy.dialect.impl.MySqlDialect) DB2Dialect(org.sagacity.sqltoy.dialect.impl.DB2Dialect) ImpalaDialect(org.sagacity.sqltoy.dialect.impl.ImpalaDialect) SqliteDialect(org.sagacity.sqltoy.dialect.impl.SqliteDialect) GuassDBDialect(org.sagacity.sqltoy.dialect.impl.GuassDBDialect) SqlServerDialect(org.sagacity.sqltoy.dialect.impl.SqlServerDialect) GuassDBDialect(org.sagacity.sqltoy.dialect.impl.GuassDBDialect) PostgreSqlDialect(org.sagacity.sqltoy.dialect.impl.PostgreSqlDialect) OceanBaseDialect(org.sagacity.sqltoy.dialect.impl.OceanBaseDialect) KingbaseDialect(org.sagacity.sqltoy.dialect.impl.KingbaseDialect) Oracle11gDialect(org.sagacity.sqltoy.dialect.impl.Oracle11gDialect) SqliteDialect(org.sagacity.sqltoy.dialect.impl.SqliteDialect) DB2Dialect(org.sagacity.sqltoy.dialect.impl.DB2Dialect) DefaultDialect(org.sagacity.sqltoy.dialect.impl.DefaultDialect) DMDialect(org.sagacity.sqltoy.dialect.impl.DMDialect) MySqlDialect(org.sagacity.sqltoy.dialect.impl.MySqlDialect) ImpalaDialect(org.sagacity.sqltoy.dialect.impl.ImpalaDialect) OracleDialect(org.sagacity.sqltoy.dialect.impl.OracleDialect) TidbDialect(org.sagacity.sqltoy.dialect.impl.TidbDialect) ClickHouseDialect(org.sagacity.sqltoy.dialect.impl.ClickHouseDialect) DMDialect(org.sagacity.sqltoy.dialect.impl.DMDialect)

Aggregations

ClickHouseDialect (org.sagacity.sqltoy.dialect.impl.ClickHouseDialect)1 DB2Dialect (org.sagacity.sqltoy.dialect.impl.DB2Dialect)1 DMDialect (org.sagacity.sqltoy.dialect.impl.DMDialect)1 DefaultDialect (org.sagacity.sqltoy.dialect.impl.DefaultDialect)1 GuassDBDialect (org.sagacity.sqltoy.dialect.impl.GuassDBDialect)1 ImpalaDialect (org.sagacity.sqltoy.dialect.impl.ImpalaDialect)1 KingbaseDialect (org.sagacity.sqltoy.dialect.impl.KingbaseDialect)1 MySqlDialect (org.sagacity.sqltoy.dialect.impl.MySqlDialect)1 OceanBaseDialect (org.sagacity.sqltoy.dialect.impl.OceanBaseDialect)1 Oracle11gDialect (org.sagacity.sqltoy.dialect.impl.Oracle11gDialect)1 OracleDialect (org.sagacity.sqltoy.dialect.impl.OracleDialect)1 PostgreSqlDialect (org.sagacity.sqltoy.dialect.impl.PostgreSqlDialect)1 SqlServerDialect (org.sagacity.sqltoy.dialect.impl.SqlServerDialect)1 SqliteDialect (org.sagacity.sqltoy.dialect.impl.SqliteDialect)1 TidbDialect (org.sagacity.sqltoy.dialect.impl.TidbDialect)1