eu.drus.jpa.unit.sql.dbunit.ext.PostgresqlConnectionFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jpa-unit-rdbms Show documentation
Show all versions of jpa-unit-rdbms Show documentation
Makes JPA Unit support SQL databases
package eu.drus.jpa.unit.sql.dbunit.ext;
import java.sql.Connection;
import org.dbunit.DatabaseUnitException;
import org.dbunit.database.DatabaseConfig;
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory;
public class PostgresqlConnectionFactory implements DbUnitConnectionFactory {
@Override
public boolean supportsDriver(final String driverClass) {
return "org.postgresql.Driver".equals(driverClass);
}
@Override
public IDatabaseConnection createConnection(final Connection connection) throws DatabaseUnitException {
final IDatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
dbUnitConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new PostgresqlDataTypeFactory());
return dbUnitConnection;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy