Uploaded image for project: 'Beehive'
  1. Beehive
  2. BEEHIVE-1201

Use of JDBC control setConnection() method may cause prepared statements to remain open

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • V.Next
    • System Controls
    • 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

      { 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

      Attachments

        Activity

          People

            grunlowen matt c
            chad_s Chad Schoettger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: