}
private static MCSConnectionPoolConfiguration getConnectionPoolConfiguration(
JDBCRepositoryFactory factory, Map properties)
throws RepositoryException {
MCSConnectionPoolConfiguration configuration =
factory.createMCSConnectionPoolConfiguration();
// Create and configure a Connection pool if there is one.
String value = (String) properties.get(POOL_ENABLED_PROPERTY);
configuration.setEnabled("true".equalsIgnoreCase(value));
int maxConnections;
int maxFreeConnections;
//int optimalFreeConnections;
int minFreeConnections;
int initialConnections;
// Get the maximum number of connections allowed.
try {
maxConnections =
getInt(properties, POOL_MAX_CONNECTIONS_PROPERTY, 10);
} catch (NumberFormatException nfe) {
throw new JDBCRepositoryException(EXCEPTION_LOCALIZER.format(
"jdbc-pool-invalid-max-connections"));
}
// Get the maximum number of free connections allowed.
try {
maxFreeConnections = getInt(properties,
POOL_MAX_FREE_CONNECTIONS_PROPERTY,
8);
} catch (NumberFormatException nfe) {
throw new JDBCRepositoryException(EXCEPTION_LOCALIZER.format(
"jdbc-pool-invalid-maxFree-connections"));
}
// Get the minimum number of free connections allowed.
try {
minFreeConnections = getInt(properties,
POOL_MIN_FREE_CONNECTIONS_PROPERTY,
2);
} catch (NumberFormatException nfe) {
throw new JDBCRepositoryException(EXCEPTION_LOCALIZER.format(
"jdbc-pool-invalid-minFree-connections"));
}
// Get the initial number of free connections created.
try {
initialConnections = getInt(properties,
POOL_INITIAL_CONNECTIONS_PROPERTY,
minFreeConnections);
} catch (NumberFormatException nfe) {
throw new JDBCRepositoryException(EXCEPTION_LOCALIZER.format(
"jdbc-pool-invalid-initial-connections"));
}
boolean keepConnectionsAlive = getKeepConnectionsAlive(properties);
int connectionPollInterval = getConnectionPollInterval(properties);
configuration.setInitialConnections(initialConnections);
configuration.setKeepAliveActive(keepConnectionsAlive);
configuration.setKeepAlivePollInterval(connectionPollInterval);
configuration.setMaxConnections(maxConnections);
configuration.setMaxFreeConnections(maxFreeConnections);
configuration.setMinFreeConnections(minFreeConnections);
return configuration;
}