Before the content, wrote a few about the Java EE Standard Blog, and now continue to improve these content, this content mainly to add a blog.
WebLogic Server uses JTA1.0.1A to implement and manage transactions WebLogic Server provides the following support: creating a unique transaction marker (XID) supporting an optional transaction name tracking the database that the transaction is involved in notifying transactions use XA overwrite 2PC perform rollback perform automatic recovery process management timeout on failure
To process a transaction:
scope of the transaction: transactions can span: EJB Access JDBC Connection JMS connection
examples of EJBS and JDBC in a transaction How transactions can be mixed across EJB method calls and JDBC connections:
...
Context Tc=new InitialContext ();
UserTransaction ut= (usertransaction)
ic.lookup ("javax.transaction.UserTransaction");
Myejbhome ejbhome= (myejbhome)
ic.lookup ("Java:com/env/ejb/myejbhome");
MYEJB ejb=ejbhome.create ();
DataSource ds= (DataSource)
ic.lookup ("Java:com.env/jdbc/mydb");
Connection con=ds.getconnection ();
Statement stmt=con.createstatement ();
Ut.begin ();
Ejb.methoda ();
Ejb.methodb ();
Stmt.executequery (...);
Stmt.executeupdate (...);
exceptions in a transaction Servlets must be aware of exceptions and their implementation in terms of transactions the EJBS involved in a transaction may throw the following exceptions: Application exceptions (Exception applied)--if the EJB marks the transaction as rollback, then the client can only roll back. If no rollback is marked, the client can commit or roll back. System or non-applied exception-The transaction is marked for rollback. The client can only roll back one, the JMS operations involved in the transaction may throw JMSException (1) The JDBC operations involved in the transaction may throw SqlException (2) in both cases, Client programs can be committed or rolled back.
examples of catching exceptions and rolling back (1) When a failure event is encountered, the transaction can perform the appropriate cleanup operation:
...
Context Ic=new InitialContext ();
UserTransaction ut= (usertransaction)
ic.lookup ("javax.transaction.UserTransaction");
Ut.begin ();
Withdraw (fromaccount,amount);
Deposit (toaccount,amount);
Ut.commit ();
} catch (Customexception e) {
System.out.println (e);
try{
ut.rollback ();
} catch (SystemException se) {
System.out.println (e);
} catch (Exception e) {
System.out.println (e);
}
}
JTA the content of the first here, our next blog will continue to improve the Java EE specifications of other blogs.