// create the connection factory
ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, dbUri, cfProps);
// wrap it with a LocalXAConnectionFactory
XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf);
// configure the pool settings
GenericObjectPool pool = new GenericObjectPool();
pool.setTimeBetweenEvictionRunsMillis(600000);
pool.setMaxActive(maxSize);
pool.setMaxIdle(maxIdle);
pool.setMinIdle(minSize);
pool.setMaxWait(120000);
// create the pool object factory
PoolableConnectionFactory factory = new PoolableConnectionFactory(xacf, pool, null, null, true, true);
factory.setValidationQuery("select example_type_id from example_type limit 1");
factory.setDefaultReadOnly(false);
String transIso = jotmJdbcElement.getAttribute("isolation-level");
if (transIso != null && transIso.length() > 0) {
if ("Serializable".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
} else if ("RepeatableRead".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
} else if ("ReadUncommitted".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
} else if ("ReadCommitted".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
} else if ("None".equals(transIso)) {
factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
}
}
pool.setFactory(factory);
mds = new ManagedDataSource(pool, xacf.getTransactionRegistry());
mds.setAccessToUnderlyingConnectionAllowed(true);
// cache the pool
dsCache.put(helperName, mds);