use of com.zaxxer.hikari.HikariDataSource in project aries by apache.
the class AbstractInternalJDBCConnectionProviderFactory method poolIfNecessary.
protected DataSource poolIfNecessary(Map<String, Object> resourceProviderProperties, DataSource unpooled) {
DataSource toUse;
if (toBoolean(resourceProviderProperties, CONNECTION_POOLING_ENABLED, true)) {
HikariConfig hcfg = new HikariConfig();
hcfg.setDataSource(unpooled);
// Sizes
hcfg.setMaximumPoolSize(toInt(resourceProviderProperties, MAX_CONNECTIONS, 10));
hcfg.setMinimumIdle(toInt(resourceProviderProperties, MIN_CONNECTIONS, 10));
// Timeouts
hcfg.setConnectionTimeout(toLong(resourceProviderProperties, CONNECTION_TIMEOUT, SECONDS.toMillis(30)));
hcfg.setIdleTimeout(toLong(resourceProviderProperties, IDLE_TIMEOUT, TimeUnit.MINUTES.toMillis(3)));
hcfg.setMaxLifetime(toLong(resourceProviderProperties, CONNECTION_LIFETIME, HOURS.toMillis(3)));
hcfg.setConnectionTestQuery(toString(resourceProviderProperties, CONNECTION_TEST_QUERY, null));
toUse = new HikariDataSource(hcfg);
} else {
toUse = unpooled;
}
return toUse;
}
use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.
the class DataSourceAutoConfigurationTests method hikariValidatesConnectionByDefault.
@Test
public void hikariValidatesConnectionByDefault() throws Exception {
HikariDataSource dataSource = autoConfigureDataSource(HikariDataSource.class, "org.apache.tomcat");
assertThat(dataSource.getConnectionTestQuery()).isNull();
// Use Connection#isValid()
}
use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.
the class HikariDataSourcePoolMetadataTests method getValidationQuery.
@Override
public void getValidationQuery() {
HikariDataSource dataSource = createDataSource(0, 4);
dataSource.setConnectionTestQuery("SELECT FROM FOO");
assertThat(new HikariDataSourcePoolMetadata(dataSource).getValidationQuery()).isEqualTo("SELECT FROM FOO");
}
use of com.zaxxer.hikari.HikariDataSource in project spring-boot by spring-projects.
the class HikariDataSourcePoolMetadataTests method createDataSource.
private HikariDataSource createDataSource(int minSize, int maxSize) {
HikariDataSource dataSource = (HikariDataSource) initializeBuilder().type(HikariDataSource.class).build();
dataSource.setMinimumIdle(minSize);
dataSource.setMaximumPoolSize(maxSize);
return dataSource;
}
use of com.zaxxer.hikari.HikariDataSource in project jDialects by drinkjava2.
the class DialectTest method buildH2Datasource.
// =======test guess dialects=======
private static HikariDataSource buildH2Datasource() {
HikariDataSource ds = new HikariDataSource();
ds.addDataSourceProperty("cachePrepStmts", true);
ds.addDataSourceProperty("prepStmtCacheSize", 250);
ds.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);
ds.addDataSourceProperty("useServerPrepStmts", true);
ds.setMaximumPoolSize(3);
ds.setConnectionTimeout(5000);
ds.setJdbcUrl("jdbc:h2:mem:DBName;MODE=MYSQL;DB_CLOSE_DELAY=-1;TRACE_LEVEL_SYSTEM_OUT=0");
ds.setDriverClassName("org.h2.Driver");
ds.setUsername("sa");
ds.setPassword("");
return ds;
}
Aggregations