How to return Connection to oracle.ucp.jdbc.PoolDataSource?

634 Views Asked by At

I have an application which uses oracle.ucp.jdbc.PoolDataSource to maintain pool of JDBC connections. I am able to get a connection and use it.

At the end of my function, I want to return the connection to the pool. I don't find any method to return the the pool.

How to return the connection to the pool?

1

There are 1 best solutions below

0
K.Nicholas On

The fine manual oracle.ucp.jdbc Class PoolDataSourceImpl

This DataSource uses the Universal Connection Pool to get a connection, creating a proxy to that connection, and returning the proxy to the client. When the client calls close on the connection proxy, the underlying physical connection is returned to the pool.

So, as noted in the comments, use connection.close(). The connection is a proxy and the close method will return the connection to the pool instead of closing the connection as is usual.