You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2010/03/30 03:19:27 UTC

[jira] Closed: (DBCP-329) SQLException: Already closed.

     [ https://issues.apache.org/jira/browse/DBCP-329?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Phil Steitz closed DBCP-329.
----------------------------

    Resolution: Fixed

When you invoke the close method on a connection managed by DBCP, you are asking DBCP to return it to the pool.  Before returning a connection to the pool, DBCP  issues the JDBC driver call, _conn.isClosed() on the underlying physical connection to make sure that it is still open.  If the driver returns false, something bad has happened, because DBCP thinks the connection is open and the driver is reporting that it is closed.  In this case, the exception that you are observing is thrown.  Your own exception handler is masking the exception that your code encountered trying to use the connection that had been closed on the server side.

See http://markmail.org/message/c2gx2xuzum4pv743 for discussion of a similar issue.  If anyone feels that DBCP should be modified to silently dispose of bad connections returned to the pool, please reopen DBCP-193.  

> SQLException: Already closed.
> -----------------------------
>
>                 Key: DBCP-329
>                 URL: https://issues.apache.org/jira/browse/DBCP-329
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: MySQL
>            Reporter: Hontvari Jozsef
>
> After upgrading to 1.4 I see such exceptions logged:
> java.sql.SQLException: Already closed.
> 	at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
> 	at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
> 	...
> This should never happen. According to the Connection.close() javadoc: 
> "Calling the method close on a Connection object that is already closed is a no-op."
>  
> Moreover, I am pretty sure that our code does not close the connection twice. But because the close() is called in a finally block, it is possible that this exception hides another exception. Unfortunately I cannot reproduce it, even though it occurs regularly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.