[
https://issues.apache.org/jira/browse/DBCP-221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13192968#comment-13192968
]
metatech commented on DBCP-221:
-------------------------------
If you wish to terminate active connections as well, you can try the following
code.
Note : the BasicDataSource must be created with the property "removeAbandoned"
set to true.
{code}
ds.setRemoveAbandonedTimeout(1);
ds.setMaxActive(1);
Connection conn = ds.getConnection();
ds.close();
conn.close();
{code}
However, with the Oracle JDBC driver, the code can fail when the active
connection waits for a database lock, because of a Java lock in the JDBC
driver.
> How to close the connection pool without shutting down the JVM while there
> are connections being used?
> ------------------------------------------------------------------------------------------------------
>
> Key: DBCP-221
> URL: https://issues.apache.org/jira/browse/DBCP-221
> Project: Commons Dbcp
> Issue Type: Bug
> Affects Versions: 1.2.2
> Reporter: Bill Liu
> Assignee: Dain Sundstrom
> Fix For: 1.3
>
>
> Suppose there are several connections being used now by different servlets.
> calling the basicDataSource,close() does not have any impact on the
> connection pool. I expect that after these servlet return the connections the
> pool should be shut down immediately. I also expect that any more requests to
> borrow connections from the pool should not be fulfilled. However, my
> experiment does not seem to support my expectations. Calling
> basicDataSource.close() seems to be ignored while there are connections being
> used.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira