7 Replies Latest reply on May 3, 2002 5:06 AM by Matt Goodall

    Connection pool implementation bug

    Matt Goodall Newbie


      There seems to be a problem with the connection pool implementation. The Statement and ResultSet objects that are obtained from a Connection in a pool are not wrapped well enough. It's possible to get a reference to the real connection and close it! Here's some (contrived) code to demonstrate the problem:

      // Create the database resources
      Datasource datasource = context.lookup("...");
      Connection conn = datasource.getConnection();
      Statement stmt = conn.createStatement();
      ResultSet rs = stmt.executeQuery("...");

      // "Reverse find" the statement and connection
      Statement stmt2 = rs.getStatement();
      Connection conn2 = stmt2.getConnection();

      // Just to demonstrate the class types

      // Closes the *real* connection.

      The first println shows a wrapped connection i.e. org.jboss.pool.jdbc.xa.wrapper.XAClientConnection. The second println shows a real connection.

      The call to conn2.close() really does closes the connection and presumably does not return it to the pool.

      Cheers, Matt