JTA Transaction management for spring integrated JOTM

Source: Internet
Author: User
Tags create database

Integrated JOTM configuration JTA transaction in spring:

If you need to use more than one database in your business, we hope that in the business method, when the transaction of the data table of one database fails and is rolled back (rollback), the operation transaction of the data table of the other database is also rolled back, but the application of general transaction management can not achieve such a transaction management effect, This requires the implementation of JTA transaction management.

Here we integrate the Object Web in spring with an open source JTA implementation Jotm (you can download the full version http://jotm.objectweb.org) to implement JTA transaction management.

1, put the necessary class package into the classpath:

Jotm.jar, Xapool.jar, Jotm_jrmp_stubs.jar, Jta-spect1_0_1.jar, Connector-1_5.jar and so on.

2, write JOTM configuration file carol.properties, put it under the classpath:

Java code

#JNDI调用协议
carol.protocols=jrmp
#不使用CAROL JNDI封装器
carol.start.jndi=false
#不启动命名服务器
carol.start.ns=false
#JNDI调用协议
carol.protocols=jrmp
#不使用CAROL JNDI封装器
carol.start.jndi=false
#不启动命名服务器
carol.start.ns=false

3, in MySQL to create two database "Jtatesta", "JTATESTB":

Java code

CREATE DATABASE IF not EXISTS Jtatesta
Use Jtatesta;
DROP TABLE IF EXISTS ' user ';
CREATE TABLE ' user ' (
' user_id ' int () unsigned not NULL auto_increment,
' user_name ' varchar (= not NUL L,
' user_password ' varchar () not NULL,
PRIMARY KEY (' user_id ')
) Engine=innodb auto_increment=5 DEFAULT Charset=latin1;
INSERT into ' user ' (' user_id ', ' user_name ', ' User_password ') VALUES
(1, ' Tufu ', ' Tufu ');
CREATE DATABASE IF not EXISTS jtatestb;
Use JTATESTB;
DROP TABLE IF EXISTS ' grade ';
CREATE TABLE ' Grade ' (
' grade_id ' int () unsigned not NULL auto_increment,
' user_id ' int (a) unsigned NO T null,
' grade ' Double NOT NULL,
PRIMARY KEY (' grade_id ')
) engine=innodb auto_increment=9 DEFAULT CHARSET =latin1;
INSERT into ' Grade ' (' grade_id ', ' user_id ', ' Grade ') VALUES
(1,0,100);
CREATE DATABASE IF not EXISTS Jtatesta;
Use Jtatesta;
DROP TABLE IF EXISTS ' user ';
CREATE TABLE ' user ' (
' user_id ' int (a) unsigned NOT null auto_increment,
' user_name ' varchar (=) NOT null,
' User_password ' Varc Har () not NULL,
PRIMARY KEY (' user_id ')
) Engine=innodb auto_increment=5 DEFAULT charset=latin1;
INSERT into ' user ' (' user_id ', ' user_name ', ' User_password ') VALUES
(1, ' Tufu ', ' Tufu ');
CREATE DATABASE IF not EXISTS jtatestb;
Use JTATESTB;
DROP TABLE IF EXISTS ' grade ';
CREATE TABLE ' Grade ' (
' grade_id ' int () unsigned not NULL auto_increment,
' user_id ' int (a) unsigned NO T null,
' grade ' Double NOT NULL,
PRIMARY KEY (' grade_id ')
) engine=innodb auto_increment=9 DEFAULT CHARSET =latin1;
INSERT into ' Grade ' (' grade_id ', ' user_id ', ' Grade ') VALUES
(1,0,100);

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.