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