1. Transaction is divided into two types, local Transaction and Global Transaction.
Involves a connection commit, called the local Transaction.
A commit that involves multiple connection, called the global Transaction.
The landlord mentioned is that Global Transaction.
2. Global Transaction requires the support of the XA interface, including inside the JTA.
of which
Javax.sql.XAConnection;
Javax.transaction.xa.Xid;
Javax.transaction.xa.XAResource;
Implementations of these XA interfaces require JDBC provision of the database.
The database itself will support XA. Database JDBC also provides the implementation of XA.
Large databases such as Oracle, Sybase, DB2, SQL Server support XA and support global Transaction.
My SQL does not support the local transaction, let alone the global transation.
3. XA requires two stages of submission-prepare and commit.
Suppose there are two connection, Con1, Con2, the general process is as follows,
if (both Pre1 and Pre2 are OK) {
XAResouce1 and 2 commits
}else {
XAResouce1 and 2 rollback
}
It was said earlier that, in the XAResouce1 and 2 commit,
Possibly XAResouce1 commit () succeeded, XAResouce2 commit () failed.
At this point, a "heuristic exception" is thrown. The program can handle this exception. For example, Xaresouce.recover ().
But in general, there is no other way, the data administrator needs to undo all operations based on the data operation log, or restore the data backup.
Some databases generate a "reverse operation" log when they perform data operations. For example, insert to delete, and so on.
4. The implementation of TransactionManager can handle multiple xaresouce (a xaresouce list).
Like Tyrex. or the transaction implementation code of an EJB server such as JBoss.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.