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. http://commons.apache.org/proper/commons-dbcp/api-1.4/org/apache/commons/dbcp/PoolableConnection.html#reallyClose() 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 overhead. Thanks, Shawn --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
