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.
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?
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.