3 Replies Latest reply on Dec 18, 2006 7:59 AM by weston.price

    How to retrieve same Connection after Activation

    amedina

      Hi there.

      We're using jboss 4.0.4 and DB2 with local-tx-datasource. Is there a way to configure the Connection-Manager in the way, that a stateful session bean gets exactly the same Connection it was holding before passivation? Also the connection shouldn't be closed at passivation.

      Thanks for your help.

        • 1. Re: How to retrieve same Connection after Activation
          weston.price

          No. You can maintain the connection handle across method invocations but not the actualy physical connection. The only way that you would be guaranteed to have the same physical connection is if a transaction spanned multiple method calls on your StatefulSessionBean and your *-ds.xml file specified that you wanted to track-by-transaction.

          Generally, this is a bad idea to begin with and requires you to explicitly enable this capability in the CachedConnectionManager.

          There is no concept of holding a connection open during passivation. Being that the bean instance is serialized to disk you should close the connection prior to passivation and reopen the connection on activation.

          • 2. Re: How to retrieve same Connection after Activation
            amedina

            Thank you for the quick reply.

            Unfortunately, this is impossible for us, cause we're opening some temporary tables on the database, which are thrown away on connection close.

            So would it be possible to write an Mbean, which holds the connections for the passivated beans?

            • 3. Re: How to retrieve same Connection after Activation
              weston.price

              Anything is possible ;-)

              Just keep in mind that resource leaks, timeouts, transaction issues etc will be common with your approach as you are going well outside of the JCA/EJB/J2EE specifications in terms of resource management.