use of com.jolbox.bonecp.BoneCPDataSource in project platformlayer by platformlayer.
the class BonecpDataSourceBuilder method buildDataSource.
@Override
public DataSource buildDataSource(String key, JdbcConfiguration jdbcConfig) {
BoneCPDataSource pooledDataSource = new BoneCPDataSource();
if (jdbcConfig.driverClassName != null) {
try {
Class.forName(jdbcConfig.driverClassName);
} catch (ClassNotFoundException e) {
log.warn("Ignoring error loading DB driver", e);
}
}
// pooledDataSource.setDriverClassName(getProperty(keyPrefix + "driverClassName"));
pooledDataSource.setJdbcUrl(jdbcConfig.jdbcUrl);
pooledDataSource.setUsername(jdbcConfig.username);
pooledDataSource.setPassword(jdbcConfig.password);
String sqlDebug = null;
if (jdbcConfig.extraProperties != null) {
sqlDebug = jdbcConfig.extraProperties.get("sql.debug");
}
Properties jdbcProperties = buildDbProperties(jdbcConfig);
if (!jdbcProperties.isEmpty()) {
try {
pooledDataSource.setDriverProperties(jdbcProperties);
} catch (Exception e) {
throw new IllegalStateException("Unable to set JDBC properties", e);
}
}
if (!Strings.isNullOrEmpty(sqlDebug)) {
pooledDataSource.setLogStatementsEnabled(Boolean.parseBoolean(sqlDebug));
}
pooledDataSource.setPartitionCount(1);
pooledDataSource.setMinConnectionsPerPartition(1);
// Don't auto-acquire new connections
// TODO: This is broken!!!
pooledDataSource.setPoolAvailabilityThreshold(0);
// Enable statement caching
pooledDataSource.setStatementsCacheSize(32);
// Track statistics
pooledDataSource.setStatisticsEnabled(true);
pooledDataSource.setConnectionHook(new BoneCPConnectionHook(key));
databaseStatistics.register(key, pooledDataSource, new BoneCpMetricsReporter(databaseStatistics.getMetricKey(key), pooledDataSource));
log.warn("Building data source for " + jdbcConfig.jdbcUrl);
return pooledDataSource;
}
use of com.jolbox.bonecp.BoneCPDataSource in project querydsl by querydsl.
the class JdbcConfiguration method dataSource.
@Bean
public DataSource dataSource() {
BoneCPDataSource dataSource = new BoneCPDataSource();
dataSource.setDriverClass(env.getRequiredProperty("jdbc.driver"));
dataSource.setJdbcUrl(env.getRequiredProperty("jdbc.url"));
dataSource.setUsername(env.getRequiredProperty("jdbc.user"));
dataSource.setPassword(env.getRequiredProperty("jdbc.password"));
return dataSource;
}
use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.
the class Case1 method test_bonecp.
public void test_bonecp() throws Exception {
BoneCPDataSource dataSource = new BoneCPDataSource();
// dataSource.(10);
// dataSource.setMaxActive(50);
dataSource.setMinConnectionsPerPartition(minPoolSize);
dataSource.setMaxConnectionsPerPartition(maxPoolSize);
dataSource.setDriverClass(driverClass);
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setStatementsCacheSize(100);
dataSource.setServiceOrder("LIFO");
// dataSource.setMaxOpenPreparedStatements(100);
dataSource.setUsername(user);
dataSource.setPassword(password);
// dataSource.setConnectionTestStatement("SELECT 1");
dataSource.setPartitionCount(1);
dataSource.setAcquireIncrement(5);
dataSource.setIdleConnectionTestPeriod(0L);
for (int i = 0; i < loopCount; ++i) {
p0(dataSource, "boneCP", threadCount);
}
System.out.println();
}
use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.
the class Case3 method boneCP.
public void boneCP() throws Exception {
BoneCPDataSource dataSource = new BoneCPDataSource();
// dataSource.(10);
// dataSource.setMaxActive(50);
dataSource.setMinConnectionsPerPartition(minIdle);
dataSource.setMaxConnectionsPerPartition(maxIdle);
dataSource.setDriverClass(driverClass);
dataSource.setJdbcUrl(jdbcUrl);
// dataSource.setPoolPreparedStatements(true);
// dataSource.setMaxOpenPreparedStatements(100);
dataSource.setUsername(user);
dataSource.setPassword(password);
dataSource.setConnectionTestStatement(validationQuery);
dataSource.setPartitionCount(1);
Properties connectionProperties = new Properties();
connectionProperties.put("connectSleep", "3");
connectionProperties.put("executeSleep", "1");
dataSource.setDriverProperties(connectionProperties);
for (int i = 0; i < TEST_COUNT; ++i) {
p0(dataSource, "boneCP", threadCount);
}
System.out.println();
}
use of com.jolbox.bonecp.BoneCPDataSource in project druid by alibaba.
the class Case4 method test_bonecp.
public void test_bonecp() throws Exception {
BoneCPDataSource dataSource = new BoneCPDataSource();
// dataSource.(10);
// dataSource.setMaxActive(50);
dataSource.setMinConnectionsPerPartition(minPoolSize);
dataSource.setMaxConnectionsPerPartition(maxPoolSize);
dataSource.setDriverClass(driverClass);
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setStatementsCacheSize(maxOpenPreparedStatements);
dataSource.setServiceOrder("LIFO");
// dataSource.setMaxOpenPreparedStatements(100);
dataSource.setUsername(user);
dataSource.setPassword(password);
// dataSource.setConnectionTestStatement("SELECT 1");
dataSource.setPartitionCount(1);
dataSource.setAcquireIncrement(5);
dataSource.setIdleConnectionTestPeriod(0L);
for (int i = 0; i < loopCount; ++i) {
p0(dataSource, "boneCP", threadCount);
}
System.out.println();
}
Aggregations