2 Replies Latest reply on Jun 18, 2003 9:34 AM by vettori

    connection autoclose and session beans

    vettori

      Hi,

      I'm using a session bean (actually a common parent and many extended classes) to implement the database searches via JDBC of my Entity Beans. The session bean has a RecordSet field that is set when the search is performed.

      The connection and prepared statement are not saved to any bean field.

      I've coded the bean this way because I can always get the statement and the connection from the result set (ResultSet.getStatement and statement.getConnection) and it is what i do when the resultset is closed and because the resultset is in the common parent class whereas the connection and prepared statement are created on the extended classes.

      The Session bean has the following methods:

      void search (...parameters...) // where the result set is created (readonly) coded in the extended classes
      object getCurrent() // get the current resultset row, coded in the extended classes

      void moveFirst() // coded in the common parent
      void moveNext()
      void movePrevious()
      and other (for paging and minor functionalities)

      The problem is that as soon as the search method returns, JBOSS closes the connection and this invalidates the saved result set.

      It seems to me that even if I store the connection and the prepared statement in two Session Bean fields, the connection is closed anyway when the search method returns.

      I found this beaviour in JBOSS 3.2 (that i use in the production environiment) and not in JBOSS 3.0.6 (that i use in the development environiment).

      Anyone can help explaining how to resolve this ?

      Thank You