use of org.dbunit.ext.mssql.MsSqlConnection in project sharding-jdbc by shardingjdbc.
the class DBUnitUtil method getConnection.
/**
* Get connection.
* @param dbEnv Database environment
* @param connection connection
* @return database connection
* @throws DatabaseUnitException DatabaseUnitException
*/
public static IDatabaseConnection getConnection(final DatabaseEnvironment dbEnv, final Connection connection) throws DatabaseUnitException {
switch(dbEnv.getDatabaseType()) {
case H2:
return new H2Connection(connection, "PUBLIC");
case MySQL:
return new MySqlConnection(connection, null);
case PostgreSQL:
DatabaseConnection databaseConnection = new DatabaseConnection(connection);
databaseConnection.getConfig().setProperty("http://www.dbunit.org/properties/datatypeFactory", new PostgresqlDataTypeFactory());
return databaseConnection;
case Oracle:
return new OracleConnection(connection, "JDBC");
case SQLServer:
return new MsSqlConnection(connection);
default:
throw new UnsupportedOperationException(dbEnv.getDatabaseType().name());
}
}
Aggregations