Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Commiting a transaction from J2EE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Commiting a transaction from J2EE" Watch "Commiting a transaction from J2EE" New topic
Author

Commiting a transaction from J2EE

Ravi Singh
Ranch Hand

Joined: Aug 02, 2004
Posts: 51
When using JDBC to execute updates in the database, if you use a statement like the following in a J2EE application:

con.commit();

does the commit action actually get executed on the database because I am under the impression that all transactions are managed by the container?

If this is the case, is the commit() method simply ignored?
PNS Subramanian
Ranch Hand

Joined: Jul 13, 2004
Posts: 150
When the transaction setting in the config file (ejb-jar.xml) is "Container", the transactions are indeed managed by the container and as per spec's, commit and rollback statements are not to be used in code.

These are to be used only incase of Bean Managed Transaction, where in the transaction setting in ejb-jar.xml file would be "Bean".

Refer http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html in case of further queries.
Ravi Singh
Ranch Hand

Joined: Aug 02, 2004
Posts: 51
Thanks.

I understand the concept of BM and CM transactions but does anyone know what would happen if you placed a commit() statement in a bean which had its transactions managed by the container?

Would an exception be thrown or would the commit simply be ignored?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Commiting a transaction from J2EE
 
Similar Threads
JDBC start/stop database needed
J2EE product that does not support two-phase commit?
MS Access data insert problem
Transaction propagation and Persistence Context synchronization with Oracle Stored Procedures
[Hibernate] Hit the database at a specific moment