I use the oracle.jdbc.pool.OracleDataSource for connection pooling. I would like the pool to check whether the connection was not closed properly and to catch it up. I tried the following:
ods = new OracleDataSource();
ods.setConnectionCachingEnabled(true);
ods.setConnectionCacheName(CACHE_NAME);
Properties cacheProps = new Properties();
cacheProps.setProperty("MinLimit", Integer.toString(1));
cacheProps.setProperty("MaxLimit", Integer.toString(6));
cacheProps.setProperty("InitialLimit", "1");
cacheProps.setProperty("AbandonedConnectionTimeout", "2");
ods.setConnectionCacheProperties(cacheProps);
I ckeck the active connections like this:
occm = OracleConnectionCacheManager.getConnectionCacheManagerInstance();
occm.getNumberOfActiveConnections(CACHE_NAME);
If I dont close the connection in the application the pool is just filling up to 6, so
cacheProps.setProperty("AbandonedConnectionTimeout", "2");
is not working. Why?
Any hint would be appreciated
Best Answer
According to Oracle's tutorial there is another property involved.
Try to also set
The default is 15 minutes...
Two seconds is probably a bit short for a connection to be considered abandoned, though, and since you have to explicitly set the check interval as well, I'd imagine that this involves some overhead. Since you really, really want to close connections properly in application code and only rely on this for very rare cases, you should probably set higher values for both.