File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Q: transaction mgt in session bean wrapping JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Q: transaction mgt in session bean wrapping JDBC" Watch "Q: transaction mgt in session bean wrapping JDBC" New topic
Author

Q: transaction mgt in session bean wrapping JDBC

Yan Zhou
Ranch Hand

Joined: Sep 02, 2003
Posts: 137
Hi,
I have some confusion as to what happens in a session bean that makes JDBC calls.

Say a stateless session bean has "Required" transaction attribute on its bussiness method, this method uses JNDI to look up data source and get a connection, and then updates database.

How would a J2EE container know this connection is part of the EJB's transaction? Is this something required by J2EE
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Basically yes it is required. When the App Server provides transaction processing, it has to monitor the entire transaction and provide all the necessary means to hold everything within the method, including JDBC stuff within that transaction.

I would suggest that the stuff done to the database be put into a POJO, most likely a DAO object, than hvaing that code directly in the Session Bean.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Q: transaction mgt in session bean wrapping JDBC