Java Code Examples for org.dbunit.ext.h2.H2DataTypeFactory

The following examples show how to use org.dbunit.ext.h2.H2DataTypeFactory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public IDatabaseConnection getConnection() throws Exception {
    IDatabaseConnection result = super.getConnection();
    DatabaseConfig dbConfig = result.getConfig();
    dbConfig.setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, false);
    dbConfig.setProperty(DatabaseConfig.FEATURE_DATATYPE_WARNING, false);
    if ("org.h2.Driver".equals(driverClass)) {
        dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
    } else if ("com.mysql.jdbc.Driver".equals(driverClass)) {
        dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MySqlDataTypeFactory());
    } else if ("org.postgresql.Driver".equals(driverClass)) {
        dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
    } else if ("oracle.jdbc.driver.OracleDriver".equals(driverClass)) {
        dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new Oracle10DataTypeFactory());
    } else if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(driverClass)) {
        dbConfig.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new MsSqlDataTypeFactory());
        
    }
    return result;
}
 
Example 2
Source Project: database-rider   Source File: RiderDataSource.java    License: Apache License 2.0 6 votes vote down vote up
private IDataTypeFactory getDataTypeFactory(DBType dbType) {
    switch (dbType) {
        case HSQLDB:
            return new HsqldbDataTypeFactory();
        case H2:
            return new H2DataTypeFactory();
        case MYSQL:
            return new MySqlDataTypeFactory();
        case POSTGRESQL:
            return new PostgresqlDataTypeFactory();
        case ORACLE:
            return new Oracle10DataTypeFactory();
        case MSSQL:
            return new MsSqlDataTypeFactory();
        case DB2:
        	return new Db2DataTypeFactory();
        default:
            return null;
    }
}
 
Example 3
Source Project: jpa-unit   Source File: H2ConnectionFactoryTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateConnection() throws DatabaseUnitException {
    // GIVEN
    final String schema = "foo";

    // WHEN
    final IDatabaseConnection dbConnection = FACTORY.createConnection(connection, schema);

    // THEN
    assertThat(dbConnection, notNullValue());

    final Object typeFactory = dbConnection.getConfig().getProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY);
    assertThat(typeFactory, notNullValue());
    assertThat(typeFactory.getClass(), equalTo(H2DataTypeFactory.class));

    assertThat(dbConnection.getSchema(), equalTo(schema));
}
 
Example 4
Source Project: metanome-algorithms   Source File: JdbcTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void cleanlyInsert(IDataSet dataSet) throws Exception {
	IDatabaseTester databaseTester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER,
		PASSWORD);
	databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
	databaseTester.setDataSet(dataSet);
	ConnectionConfigurator operationListener = new ConnectionConfigurator()
		.setDataTypeFactory(new H2DataTypeFactory());
	databaseTester.setOperationListener(operationListener);
	databaseTester.onSetup();
}
 
Example 5
Source Project: find   Source File: SavedSearchTestConfiguration.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("ProhibitedExceptionDeclared")
@Bean
public DatabaseDataSourceConnection testConnection(final DataSource dataSource) throws Exception {
    final DatabaseConfigBean databaseConfigBean = new DatabaseConfigBean();
    databaseConfigBean.setDatatypeFactory(new H2DataTypeFactory());
    databaseConfigBean.setCaseSensitiveTableNames(false);

    final DatabaseDataSourceConnectionFactoryBean databaseDataSourceConnectionFactoryBean = new DatabaseDataSourceConnectionFactoryBean();
    databaseDataSourceConnectionFactoryBean.setDataSource(dataSource);
    databaseDataSourceConnectionFactoryBean.setDatabaseConfig(databaseConfigBean);
    databaseDataSourceConnectionFactoryBean.setSchema("FIND");

    return databaseDataSourceConnectionFactoryBean.getObject();
}
 
Example 6
Source Project: Zebra   Source File: SingleDBBaseTestCase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected void setUpDatabaseConfig(DatabaseConfig config) {
	config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory());
}