commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Heisey <>
Subject Re: I need to close the connection, not return it back to the Connection Pool
Date Thu, 22 Dec 2016 16:34:10 GMT
On 12/22/2016 4:49 AM, 王钦 wrote:
>     When I use DBCP-1.4 in my work, I need to close the connection
> which is generated by BasicDataSource. How can I do it? Close the
> connection, while not returning it back to the Connection Pool. 

The PoolableConnection class (which I believe is the actual type of
object you will receive from the data source) has a "reallyClose()" method.

I'm no expert, but I think you might be able to cast the connection
received from BasicDataSource to the Poolable variety.

If you intend to "reallyClose()" every connection (rather than just some
of them), I do have to wonder why you're using DBCP at all.  Obtaining
connections from JDBC directly and closing them normally would
accomplish the same thing without a code dependency and slightly less


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message