J2EE application components can use the Java Transaction API (JTA) UserTransaction interface to manage transactions. A component instance can look up an object that implements the interface using the JNDI name java:comp/UserTransaction.
In this code sample, an application component uses the interface to manage a transaction:
// Get the initial JNDI context Context initContext = new InitialContext(); // Look up the UserTransaction object UserTransaction tran = (UserTransaction) initContext.lookup(“java:comp/UserTransaction”); // Start a transaction tran.begin(); // data updates // Commit the transaction tran.commit();