dcsimg
Calling close()/commit() on java.sql.Connection (in WebLogic Server 6.1) ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   timo_maenpaa
Posted On:   Monday, November 25, 2002 05:21 AM

I have a servlet calling a stateless session bean. The call starts a transction (container managed transaction). Then the session bean calls a BMP entity bean that joins the transaction. The BMP entity uses the WebLogic TxDataSource to take a JDBC connection to Oracle. As far as I understands the JDBC connection (from TxDataSource) joins to the transaction that started in the call to the stateless session bean ? As far as I understand the transaction rollbacks/commits when the method call from the stateless session returns ? But what I should do with the reference to JDBC connection I took in the BMP entity bean ? Should I call the close() method (at least I think that calling it does nothing) ? Should I call the commit()    More>>

I have a servlet calling a stateless session bean. The call starts a transction (container managed transaction). Then the session bean calls a BMP entity bean that joins the transaction. The BMP entity uses the WebLogic TxDataSource to take a JDBC connection to Oracle.


As far as I understands the JDBC connection (from TxDataSource) joins to the transaction that started in the call to the stateless session bean ? As far as I understand the transaction rollbacks/commits when the method call from the stateless session returns ?


But what I should do with the reference to JDBC connection I took in the BMP entity bean ? Should I call the close() method (at least I think that calling it does nothing) ? Should I call the commit() method (at least I think that calling it does nothing) ?


thanks,
Timo

   <<Less

Re: Calling close()/commit() on java.sql.Connection (in WebLogic Server 6.1) ?

Posted By:   Anonymous  
Posted On:   Thursday, January 16, 2003 06:01 AM

The container will call the commit and rollback for you. If an exception occurs that causes you to want to rollback you need to tell the container that the transaction should be aborted. You do this by calling EJBContext.setRollbackOnly() (where EJBContext is a SessionContext or an EntityContext in the case of entity beans).



The
EJB spec
indicates that when using container managed transactions that you should not call commit, rollback or setAutocommit on the connection. You do need to call close in order to release the connection back into the pool.


Take a look at section 17.3.4, it should give you some more details.





Cortez
About | Sitemap | Contact