Search in sources :

Example 1 with Db2Container

use of org.testcontainers.containers.Db2Container in project spring-data-jdbc by spring-projects.

the class Db2DataSourceConfiguration method createDataSource.

/*
	 * (non-Javadoc)
	 * @see org.springframework.data.jdbc.testing.DataSourceConfiguration#createDataSource()
	 */
@Override
protected DataSource createDataSource() {
    if (DB_2_CONTAINER == null) {
        LOG.info("DB2 starting...");
        Db2Container container = new Db2Container().withReuse(true);
        container.start();
        LOG.info("DB2 started");
        DB_2_CONTAINER = container;
    }
    return new DriverManagerDataSource(DB_2_CONTAINER.getJdbcUrl(), DB_2_CONTAINER.getUsername(), DB_2_CONTAINER.getPassword());
}
Also used : DriverManagerDataSource(org.springframework.jdbc.datasource.DriverManagerDataSource) Db2Container(org.testcontainers.containers.Db2Container)

Aggregations

DriverManagerDataSource (org.springframework.jdbc.datasource.DriverManagerDataSource)1 Db2Container (org.testcontainers.containers.Db2Container)1