org.dbunit.ext.mysql.MySqlConnection Java Examples

The following examples show how to use org.dbunit.ext.mysql.MySqlConnection. 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
Source File: DBUnitUtil.java    From sharding-jdbc-1.5.1 with Apache License 2.0 6 votes vote down vote up
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());
    }
}
 
Example #2
Source File: FosstrakDatabaseHelper.java    From fosstrak-epcis with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static IDatabaseConnection getDatabaseConnection() throws ClassNotFoundException, SQLException,
        DatabaseUnitException {
    Class.forName("com.mysql.jdbc.Driver");
    Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/epcis?autoReconnect=true",
            "epcis", "epcis");
    IDatabaseConnection connection = new MySqlConnection(jdbcConnection, "epcis");
    return connection;
}
 
Example #3
Source File: UsageSanityCheckerIT.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PropertiesUtil.loadFromFile(properties, PropertiesUtil.findConfigFile("db.properties"));

    Class.forName("com.mysql.jdbc.Driver");
    cloudConn = createConnection("cloud");
    usageConn = createConnection("usage");

    dbuCloudConn = new MySqlConnection(cloudConn, properties.getProperty("db.cloud.name"));
    dbuUsageConn = new MySqlConnection(usageConn, properties.getProperty("db.usage.name"));
    cloudDataSet = getCloudDataSet();
    usageDataSet = getUsageDataSet();
    DatabaseOperation.CLEAN_INSERT.execute(dbuCloudConn, cloudDataSet);
    DatabaseOperation.CLEAN_INSERT.execute(dbuUsageConn, usageDataSet);
}
 
Example #4
Source File: MySqlConnectionFactory.java    From jpa-unit with Apache License 2.0 4 votes vote down vote up
@Override
public IDatabaseConnection createConnection(final Connection connection, final String schema) throws DatabaseUnitException {
    return new MySqlConnection(connection, schema);
}