views:

24

answers:

1

Hi

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

Thanks

Marcel i

+1  A: 

According to Oracle's tutorial there is another property involved.

When the cache is created, three important properties, the PropertyCheckInterval, AbandonedConnectionTimeout and LowerThresholdLimit are set. PropertyCheckInterval sets the time interval at which the cache manager inspects and enforces all specified cache properties.

Try to also set

 cacheProps.setProperty("PropertyCheckInterval", "1");

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.

Thilo
Thanks very much...
Marcel Menz