* also be used for setting up the per-thread pools.
*/
private ResourceLimitingJdbcDataSource initPool(String maxPool) {
ResourceLimitingJdbcDataSource source = null;
source = new ResourceLimitingJdbcDataSource();
DefaultConfiguration config = new DefaultConfiguration("rl-jdbc"); // $NON-NLS-1$
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder(40);
sb.append("MaxPool: ");
sb.append(maxPool);
sb.append(" Timeout: ");
sb.append(getTimeout());
sb.append(" TrimInt: ");
sb.append(getTrimInterval());
sb.append(" Auto-Commit: ");
sb.append(isAutocommit());
log.debug(sb.toString());
}
DefaultConfiguration poolController = new DefaultConfiguration("pool-controller"); // $NON-NLS-1$
poolController.setAttribute("max", maxPool); // $NON-NLS-1$
poolController.setAttribute("max-strict", "true"); // $NON-NLS-1$ $NON-NLS-2$
poolController.setAttribute("blocking", "true"); // $NON-NLS-1$ $NON-NLS-2$
poolController.setAttribute("timeout", getTimeout()); // $NON-NLS-1$
poolController.setAttribute("trim-interval", getTrimInterval()); // $NON-NLS-1$
config.addChild(poolController);
DefaultConfiguration autoCommit = new DefaultConfiguration("auto-commit"); // $NON-NLS-1$
autoCommit.setValue(String.valueOf(isAutocommit()));
config.addChild(autoCommit);
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder(40);
sb.append("KeepAlive: ");
sb.append(isKeepAlive());
sb.append(" Age: ");
sb.append(getConnectionAge());
sb.append(" CheckQuery: ");
sb.append(getCheckQuery());
log.debug(sb.toString());
}
DefaultConfiguration cfgKeepAlive = new DefaultConfiguration("keep-alive"); // $NON-NLS-1$
cfgKeepAlive.setAttribute("disable", String.valueOf(!isKeepAlive())); // $NON-NLS-1$
cfgKeepAlive.setAttribute("age", getConnectionAge()); // $NON-NLS-1$
cfgKeepAlive.setValue(getCheckQuery());
poolController.addChild(cfgKeepAlive);
String _username = getUsername();
if (log.isDebugEnabled()) {
StringBuilder sb = new StringBuilder(40);
sb.append("Driver: ");
sb.append(getDriver());
sb.append(" DbUrl: ");
sb.append(getDbUrl());
sb.append(" User: ");
sb.append(_username);
log.debug(sb.toString());
}
DefaultConfiguration cfgDriver = new DefaultConfiguration("driver"); // $NON-NLS-1$
cfgDriver.setValue(getDriver());
config.addChild(cfgDriver);
DefaultConfiguration cfgDbUrl = new DefaultConfiguration("dburl"); // $NON-NLS-1$
cfgDbUrl.setValue(getDbUrl());
config.addChild(cfgDbUrl);
if (_username.length() > 0){
DefaultConfiguration cfgUsername = new DefaultConfiguration("user"); // $NON-NLS-1$
cfgUsername.setValue(_username);
config.addChild(cfgUsername);
DefaultConfiguration cfgPassword = new DefaultConfiguration("password"); // $NON-NLS-1$
cfgPassword.setValue(getPassword());
config.addChild(cfgPassword);
}
// log is required to ensure errors are available
source.enableLogging(new LogKitLogger(log));