*/
private final BoneCP connectionPool;
protected BasePooledConnectionProvider(Configuration pluginConfig) throws Exception {
this.pluginConfig = pluginConfig;
BoneCPConfig bconfig = new BoneCPConfig(getConnectionProperties());
Class<Driver> driverClass;
try {
driverClass = getDriverClass();
} catch (ClassNotFoundException e) {
LOG.warn("Could not load driver class from: " + Thread.currentThread().getContextClassLoader());
throw e;
}
if (driverClass != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Using driver class " + driverClass);
}
Driver driver = driverClass.newInstance();
DataSource datasourceBean = new DriverDataSource(driver, getJdbcUrl(), getConnectionProperties());
bconfig.setDatasourceBean(datasourceBean);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Using driver manager for " + getJdbcUrl());
}
bconfig.setJdbcUrl(getJdbcUrl());
}
bconfig.setAcquireIncrement(1);
bconfig.setAcquireRetryAttempts(0);
bconfig.setAcquireRetryDelayInMs(0);
bconfig.setPartitionCount(2);
bconfig.setMaxConnectionsPerPartition(5);
bconfig.setPassword(getPassword());
bconfig.setUsername(getUsername());
bconfig.setConnectionTimeoutInMs(getConnectionTimeout());
if (isTrack()) {
bconfig.setCloseConnectionWatch(true);
bconfig.setCloseConnectionWatchTimeout(10, TimeUnit.MINUTES);
}
bconfig.setLazyInit(false);
bconfig.setDisableJMX(true);
// Do not manage retry
ConnectionHook hook = new AbstractConnectionHook() {
public boolean onAcquireFail(Throwable t, AcquireFailConfig acquireConfig) {
LOG.error("Failed to obtain connection", t);
return false;
}
};
bconfig.setConnectionHook(hook);
connectionPool = new BoneCP(bconfig);
}