beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chad Schoettger (JIRA)" <j...@apache.org>
Subject [jira] Created: (BEEHIVE-1201) Use of JDBC control setConnection() method may cause prepared statements to remain open
Date Tue, 10 Jul 2007 17:24:04 GMT
Use of JDBC control setConnection() method may cause prepared statements to remain open
---------------------------------------------------------------------------------------

                 Key: BEEHIVE-1201
                 URL: https://issues.apache.org/jira/browse/BEEHIVE-1201
             Project: Beehive
          Issue Type: Bug
          Components: System Controls
            Reporter: Chad Schoettger
            Assignee: Chad Schoettger


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 {
               ps.close();
           }
           catch (SQLException sqe) {
               // noop
           }
       }

       getResources().clear();

       if (_connection != null && !_externalConnection) {
/*************************** Code Inserted
***************************************/
          try {
                 _connection.close();
           }
           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


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


Mime
View raw message