4 Replies Latest reply on Jun 26, 2002 1:47 AM by David Jencks

    jBoss-3.0, JCA and PreparedStatement

    Oleg Yurkivskyy Newbie

      Hi everyone.

      It looks like there is a bug in
      org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.java. This PreparedStatement implementation doesn't override close() call (inherited from LocalStatement.java). As a result, an application call to PreparedStatement.close() doesn't close the internal ps object (ps is declared as private final PreparedStatement).
      When I switched from jBoss-2.4.X to jBoss-3.0.0, my EJB applicaton (a replica of Java Pet Store) ran out of opened cursors on the ORACLE database after a while.
      I'm using PreparedStatements and code always calls rs.close(),pstmt.close(),conn.close() at the end of the thansactional method (container managed transaction demarcation, type require).
      The latest CVS code (jboss-call/connector/src/main) still has this error. I wonder if anyone is using PreparedStatements with LocalTxCM wrapper (ORACLE driver)? Are you having same problem?
      Can anyone confirm bug or explain what has changed since jBoss-2.4 with PreparedStatements managements?
      Regards,
      Oleg.

        • 1. Re: jBoss-3.0, JCA and PreparedStatement
          David Jencks Master

          The jdbc support has been completely rewritten since 2.4 with the exception of the xa wrapper code.

          Maybe I'm really missing something here, but I don't see how the code is wrong.

          LocalPreparedStatement constructor:
          public LocalPreparedStatement(final LocalConnection lc, final PreparedStatement ps)
          {
          super(lc, ps);
          ...

          LocalStatement constructor:

          public LocalStatement(final LocalConnection lc, Statement s)
          {
          this.lc = lc;
          this.s = s;
          }


          LocalStatement.close():
          public void close() throws SQLException
          {
          try
          {
          s.close();
          }

          ...

          This should execute the close method on the actual type of the Object referenced by s, which is presumably your Oracle PreparedStatement.

          I'm not sure why your code wouldn't work. Are you getting any exceptions before you run out of cursors?

          • 2. Re: jBoss-3.0, JCA and PreparedStatement
            Oleg Yurkivskyy Newbie

            David, sorry you are right about close() method.

            I'm not sure why the code has stopped working.
            I'll further investigate it.
            Is there a possibility for ResultSet not been closed (despite the fact of call rs.close() in the application)? I couldn't figure out where is the relevant connector code (like LocalPreparedStatement).
            There are no exceptions whatsoever in the application until ORACLE generate the "opened cursor limit reached" error and subsequent exception.
            All I did - I have changed version of jBoss from 2.4 to 3.0. .ear file is exactly same.

            • 3. Re: jBoss-3.0, JCA and PreparedStatement
              Oleg Yurkivskyy Newbie

              Sorry David, you are right about close() method.

              I didn't get any exceptions until ORCALE has generated "opened cursor limit reached" error and subsequent SQL exception.

              All I have changed is the version of jBoss: 2.4 -> 3.0. The .ear file is the same.

              I'll investigate the issue further anyway. I was unable to find the JCA code, relevant to ResultSet.close(). ORACLE might expect this call in order to close cursor. Is there any proxy object between ResultSet of JDBC driver and ResultSet of the application?

              Thanks

              • 4. Re: jBoss-3.0, JCA and PreparedStatement
                David Jencks Master

                There is no wrapper for ResultSet, despite some complaints. So if you are calling rs.close(), the Oracle result set is what is closed. I hope you can find out what is wrong!