use of org.apache.commons.dbcp2.BasicDataSource in project spring-boot by spring-projects.
the class SimpleTwoDataSourcesExampleTests method validateConfiguration.
@Test
public void validateConfiguration() throws SQLException {
assertThat(this.context.getBeansOfType(DataSource.class)).hasSize(2);
DataSource dataSource = this.context.getBean(DataSource.class);
assertThat(this.context.getBean("fooDataSource")).isSameAs(dataSource);
assertThat(dataSource.getConnection().getMetaData().getURL()).startsWith("jdbc:h2:mem:");
BasicDataSource barDataSource = this.context.getBean("barDataSource", BasicDataSource.class);
assertThat(barDataSource.getUrl()).isEqualTo("jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1");
assertThat(barDataSource.getMaxTotal()).isEqualTo(42);
}
use of org.apache.commons.dbcp2.BasicDataSource in project Axe by DongyuCai.
the class DbcpDataSourceFactory method init.
private void init() {
try {
DATA_SOURCE = new BasicDataSource();
DATA_SOURCE.setDriverClassName(DRIVER);
DATA_SOURCE.setUrl(URL);
DATA_SOURCE.setUsername(USERNAME);
DATA_SOURCE.setPassword(PASSWORD);
} catch (Exception e) {
LOGGER.error("jdbc driver : " + DRIVER);
LOGGER.error("jdbc url : " + URL);
LOGGER.error("jdbc username : " + USERNAME);
LOGGER.error("jdbc password : " + PASSWORD);
LOGGER.error("load jdbc driver failure", e);
}
}
Aggregations