String txIsolation = getConfigurationString(context,
ConfigurationConstants.CONFIG_TX_ISOLATION_LEVEL,
ConfigurationConstants.OLD_CONFIG_TX_ISOLATION_LEVEL,
TransactionIsolation.READ_COMMITTED.getName());
TransactionIsolation txIsolationLevel =
TransactionIsolation.getByName(txIsolation);
LOGGER.debug("Transaction isolation will be set to: " + txIsolationLevel);
// Setup Datasource
ConnectionFactory connFactory =
new DriverManagerConnectionFactory(connectUrl, jdbcProps);
connectionPool = new GenericObjectPool();
String maxActiveConnections = getConfigurationString(context,
ConfigurationConstants.CONFIG_MAX_CONNECTIONS,
ConfigurationConstants.OLD_CONFIG_MAX_CONNECTIONS, "10");
int maxActive = 10;
if (maxActiveConnections != null && maxActiveConnections.length() > 0) {
try {
maxActive = Integer.parseInt(maxActiveConnections);
} catch (NumberFormatException nfe) {
LOGGER.warn("Max active connections has invalid value: "
+ maxActiveConnections + ", Using default: " + maxActive);
}
}
LOGGER.debug("Max active connections for the pool: " + maxActive);
connectionPool.setMaxActive(maxActive);
statementPool = new GenericKeyedObjectPoolFactory(null);
// Creating the factory instance automatically wires the connection pool
new PoolableConnectionFactory(connFactory, connectionPool, statementPool,
databaseType.getValidationQuery(), false, false,
txIsolationLevel.getCode());
dataSource = new PoolingDataSource(connectionPool);
txFactory = new JdbcTransactionFactory(dataSource, this);
}