Search code examples
javaoracleconnection-pooling

Oracle Connection Pooling in Java


I have some questions on connection pooling with java and an oracle db. From the oracle documentation for the refreshCache method

When invoked with REFRESH_ALL_CONNECTIONS, all available connections in the cache are closed and replaced with new valid physical connections.

The phrase 'all available connections in the cache' does this refer only to inactive connections or all connections whether active or not?

Secondly having purged a cache so there are no connections in the cache, the next time I call the getConnection method I get a closed connection. Is there something I may be missing with the purge method?

http://docs.oracle.com/cd/B14117_01/java.101/b10979/conncache.htm


Solution

  • 1) Oracle refers to the cache as the actual connection pool. There are some other caching features of the Oracle Driver, but that's not what they are referring to here.

    2) Whenever I setup a connection pool, I always enable the ability to validate the connection when its borrowed from the pool. It adds a little extra latency, however it ensures I get a valid connection from the pool.