1
votes

Looking for advice on best practice for getting Connections when using the Oracle UCP Connection Pool Manager. I can't tell from the documentation if you're supposed to keep refs to your PoolDataSource objects, and get the Connections from them, or if you should just use your Manager to get Connections with some code like this:

(Connection)getConnectionPool(connectionPoolName).borrowConnection(getRetrievalMap().get(connectionPoolName)).getPhysicalConnection();

All the examples seem to use the PoolDataSource objects to get their connections. Do people keep those around, and then just use the Manager to do adminstrative things with the Pools? Or do they get the java.sql.Connection objects directly from the Manager with getPhysicalConnection()? I'm a little worried about using getPhysicalConnection(), not sure if the pool would know about it. For example, would closing a Connection obtained with getPhysicalConnection() go back into the pool?

Is there a better way to get Connections from the Manager that I'm not seeing?

1
Well done! You should post an answer to your own question when you are able to solve the problem by yourself.Antonio
I took your advice. I'd still like to know if anyone gets their connections from the PoolManager, and if so, how.medloh

1 Answers

2
votes

Answering my own question:

After some debugging, it looks like we shouldn't be using getPhysicalConnection() when using a pool. Doing a close() on it doesn't return it to the pool right away, where a close() on a connection from PoolDataSource does go right back into the Pool. Also, the physical connection is an instance of TC4Connection, where the Connection from PoolDataSource is a Proxy with some pooling fields and a reference to the T4CConnection.

So I guess we'll be saving the PoolDataSource objects and get our connections from them. I wish the Oracle docs would cover this topic in the Manager chapter.