You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/04/07 11:22:22 UTC
DO NOT REPLY [Bug 28251] New: -
Returning dead database connections to BasicDataSource
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28251>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28251
Returning dead database connections to BasicDataSource
Summary: Returning dead database connections to BasicDataSource
Product: Commons
Version: 1.1 Final
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: Dbcp
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: ajul.shah@jpmorgan.com
I have been using the BasicDataSource class to do connection pooling. I am
using sybase version 12.0.0.8 with jconnect 5.5.
The problem is if you get a connection from the pool and before it is handed
back the physical connection dies then there is no way to hand that connection
back to the pool so it remains as an active connection when it is actually dead.
I would expect the following behaviour when handing back a connection:-
- if the connection is ok, place in the pool
- if the connection is not valid for any reason then it should be closed
I think the problem lies in the following code in PoolableConnection class. If
the isClosed() method returns true then an SQLExceptoin is thrown and then you
can never return the connection to the pool, hence leaving an active connection
that doesn;t actually exist anymore.
public synchronized void close() throws SQLException {
if(isClosed()) {
throw new SQLException("Already closed.");
} else {
try {
_pool.returnObject(this);
} catch(SQLException e) {
throw e;
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new SQLNestedException("Cannot close connection (return
to pool failed)", e);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org