/** * 从DataSoure中取出connection, 根据connection的metadata中的jdbcUrl判断Dialect类型. * 仅支持Oracle 10, H2, MySql, PostgreSql, SQLServer,如需更多数据库类型,请仿照此类自行编写。 */ public static String getDialect(DataSource dataSource) { switch (getDBType(dataSource)) { case H2: return H2Dialect.class.getName(); case MYSQL: return MySQLDialectWithoutFK.class.getName(); case ORACLE: return Oracle10gDialectWithoutFK.class.getName() ; case POSTGRESQL: return PostgreSQL9DialectWithoutFK.class.getName() ; case SQL_SERVER: return SQLServer2008Dialect.class.getName(); } throw new IllegalArgumentException("未知的数据库类型"); }
/** * 从DataSoure中取出connection, 根据connection的metadata中的jdbcUrl判断Dialect类型. * 仅支持Oracle, H2, MySql, PostgreSql, SQLServer,如需更多数据库类型,请仿照此类自行编写。 */ public static String getDialect(DataSource dataSource) { String jdbcUrl = getJdbcUrlFromDataSource(dataSource); // 根据jdbc url判断dialect if (StringUtils.contains(jdbcUrl, ":h2:")) { return H2Dialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":mysql:")) { return MySQL5InnoDBDialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":oracle:")) { return Oracle10gDialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":postgresql:")) { return PostgreSQL82Dialect.class.getName(); } else if (StringUtils.contains(jdbcUrl, ":sqlserver:")) { return SQLServer2008Dialect.class.getName(); } else { throw new IllegalArgumentException("Unknown Database of " + jdbcUrl); } }
private void addDialects(StrategySelectorImpl strategySelector) { addDialect( strategySelector, Cache71Dialect.class ); addDialect( strategySelector, CUBRIDDialect.class ); addDialect( strategySelector, DB2Dialect.class ); addDialect( strategySelector, DB2390Dialect.class ); addDialect( strategySelector, DB2400Dialect.class ); addDialect( strategySelector, DerbyTenFiveDialect.class ); addDialect( strategySelector, DerbyTenSixDialect.class ); addDialect( strategySelector, DerbyTenSevenDialect.class ); addDialect( strategySelector, FirebirdDialect.class ); addDialect( strategySelector, FrontBaseDialect.class ); addDialect( strategySelector, H2Dialect.class ); addDialect( strategySelector, HSQLDialect.class ); addDialect( strategySelector, InformixDialect.class ); addDialect( strategySelector, IngresDialect.class ); addDialect( strategySelector, Ingres9Dialect.class ); addDialect( strategySelector, Ingres10Dialect.class ); addDialect( strategySelector, InterbaseDialect.class ); addDialect( strategySelector, JDataStoreDialect.class ); addDialect( strategySelector, MckoiDialect.class ); addDialect( strategySelector, MimerSQLDialect.class ); addDialect( strategySelector, MySQL5Dialect.class ); addDialect( strategySelector, MySQL5InnoDBDialect.class ); addDialect( strategySelector, MySQL5Dialect.class ); addDialect( strategySelector, MySQL5InnoDBDialect.class ); addDialect( strategySelector, Oracle8iDialect.class ); addDialect( strategySelector, Oracle9iDialect.class ); addDialect( strategySelector, Oracle10gDialect.class ); addDialect( strategySelector, PointbaseDialect.class ); addDialect( strategySelector, PostgresPlusDialect.class ); addDialect( strategySelector, PostgreSQL81Dialect.class ); addDialect( strategySelector, PostgreSQL82Dialect.class ); addDialect( strategySelector, PostgreSQL9Dialect.class ); addDialect( strategySelector, ProgressDialect.class ); addDialect( strategySelector, SAPDBDialect.class ); addDialect( strategySelector, SQLServerDialect.class ); addDialect( strategySelector, SQLServer2005Dialect.class ); addDialect( strategySelector, SQLServer2008Dialect.class ); addDialect( strategySelector, Sybase11Dialect.class ); addDialect( strategySelector, SybaseAnywhereDialect.class ); addDialect( strategySelector, SybaseASE15Dialect.class ); addDialect( strategySelector, SybaseASE157Dialect.class ); addDialect( strategySelector, TeradataDialect.class ); addDialect( strategySelector, TimesTenDialect.class ); }