jQuery in Action, 2nd edition
The moose likes JDBC and the fly likes Commiting a transaction from J2EE Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Commiting a transaction from J2EE
 
Similar Threads
JDBC start/stop database needed
Transaction propagation and Persistence Context synchronization with Oracle Stored Procedures
MS Access data insert problem
[Hibernate] Hit the database at a specific moment
J2EE product that does not support two-phase commit?