File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes 2 phase commit using UserTransaction without EJB 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 "2 phase commit using UserTransaction without EJB" Watch "2 phase commit using UserTransaction without EJB" New topic

2 phase commit using UserTransaction without EJB

Vijay Bala

Joined: Oct 25, 2001
Posts: 25
Is it possible to use 2 phase commit without using EJB ?
This is what i want to do:
InitialContext ctx = new InitialContext();
javax.transaction.UserTransaction userTran = ctx.getuserTransaction();
try {
do updates to 2 distributed databases
} catch(Exception e) { userTran.rollback() }

2. Another optionI have seen is :
java.util.Properties env = ..
Context ctx = new IntialContext(env);
userTran = (userTransaction)ctx.lookup("java:comp/UserTransaction");
Rest of the code is the same.
Can i use such code in a simple helper class which is called by a servlet or does it have to be within a Session bean ? All i reallyw ant to do is geta UserTransaction instance and do updates to 2 databases within the transaction without using EJB ? I can't use EJB becoz the client doesn't want to use it.
Consider Paul's rocket mass heater.
subject: 2 phase commit using UserTransaction without EJB
Similar Threads
can non-ejb client pass its transaction to ejb?
System exception on UserTransaction.commit() , followed by RollbackException
UserTransaction object in remote client
Accessing UserTransaction object on JBoss 4.0.1 from remote client
Transaction support in WAS 5.0