Spring Distributed Transaction Implementation __spring

Source: Internet
Author: User

A distributed transaction is a transaction that operates between multiple databases, and the Org.springframework.transaction.jta.JtaTransactionManager of spring provides distributed transaction support. If you use the JTA support of was, change its properties to the WebSphere corresponding TransactionManager.
Under Tomcat, there is no distributed transaction, but it can be implemented with the help of Third-party software Jotm (Java Open Transaction Manager) and atomikostransactionsessentials. Distributed transactions are implemented through JTA (Jotm,atomikos) in spring.
1, http://jotm.objectweb.org/
2, Http://www.atomikos.com/Main/TransactionsEssentials

First, use JOTM example
(1) DAO and its realization

Genericdao Interface:
[Java] view plain copy print?         Public interface Genericdao {public int Save (string ds, String sql, object[] obj) throws Exception;    public int Findrowcount (string ds, String sql); }

Genericdaoimpl implementation:[Java]  View plain  copy  print? public class genericdaoimpl implements genericdao{           private  JdbcTemplate jdbcTemplateA;       private   JdbcTemplate jdbcTemplateB;          public void  setjdbctemplatea (jdbctemplate jdbctemplate)  {            this.jdbcTemplateA = jdbcTemplate;       }          public void setjdbctemplateb (jdbctemplate jdbctemplate)  {           this.jdbctemplateb = jdbctemplate ;       }               Public int save (String ds, string sql, object[] oBJ)  throws Exception{           if (null ==  ds | |   "". Equals (ds))  return -1;           try{                if (ds.equals ("A")) {                    return  this.jdbctemplatea.update (sql, obj);                }else{                    return this.jdbctemplateb.update (sql, obj);                }            }catch (exception e) {               &Nbsp;e.printstacktrace ();                Throw new exception (Failed while executing the  + ds +  database). ");           }       }           public int findrowcount (string ds, string  SQL)  {           if

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.