Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
When setConnection(con) is used, the prepared statements created by the JdbcControl, are not closed as part of the onRelease event.
Eventually my connection pool becomes exhausted as the connections aren't closed completely. (SLEEPING)
I altered the JdbcControl to close these prepared statements and my connections are released.
Specifically I moved the code
if (_connection != null && !_externalConnection) {
}
From the onRelease() method to the cleanupConnection() method to allow the PreparedStatements to be closed.
IE
private void cleanupConnection() {
for (PreparedStatement ps : getResources()) {
try
catch (SQLException sqe)
{ // noop }}
getResources().clear();
if (_connection != null && !_externalConnection) {
/*************************** Code Inserted
***************************************/
try
catch (SQLException e)
{ throw new ControlException("SQL Exception while attempting to close database connection.", e); } _connection = null;
_externalConnection = false;
}
}
Environment
Beehive 1.0.2
Tomcat 5.5.20
Apache commons connection pool
(org.apache.commons.dbcp.BasicDataSourceFactory)
JTDS open source driver (net.sourceforge.jtds.jdbc.Driver)
SQL Server 2005