#
#
# JDBC Distributive example
#
#
# $Id: README.txt,v 1.2 2005/04/18 16:50:56 rogerperey Exp $
Scenario:
---------
The JDBC Distributive example is a simple example showing how
to use JTA transactions with two JDBC databases.
Setup:
------
o A RMI registry
o JOTM is the Transaction Manager
o A database:
- Oracle
- MySQL
- PostgreSQL
o DistDatabaseHelper setups the JDBC objects (i.e., the JDBC Connections) with Enhydra
wrappers and associates them to JOTM as their transaction manager.
o JdbcDistExample then will ask the DistDatabaseHelper for two connections, update a table
in two different databases within a transaction and complete this transaction thanks to
arguments given by the user.
Database Setup:
---------------
The example expects:
o a database named javatest for each host name
If using localhost, define two databases named
javatest1 and javatest2
Change the SQL commands in the java code to reference
the javatest1 and javatest2 databases
o a user of login "mojo" and password "jojo"
o a *transactional* table named testdata which is like
+----+-------+
| ID | FOO |
+----+-------+
| 1 | 1 |
+----+-------+
o id being an int (primary key)
o foo being an int
For example on MySQL:
$$$ Note: Use below for javatest1 and repeat for javatest2 $$$
mysql> GRANT ALL PRIVILEGES ON *.* TO [userid]
-> IDENTIFIED BY '[password]' WITH GRANT OPTION;
mysql> create database javatest1;
mysql> use javatest1;
mysql> create table testdata (
-> id int not null auto_increment primary key,
-> foo int)type=InnoDB;
mysql> insert into testdata values(null, 1);
Database configuration are stored in properties file (mysql1.propertiesand mysql2.properties,
postgresql1.properties and postgress2.properties, and oracle1.properties and oracle2.properties)
which contains the following properties:
o driver - Name of the JDBC driver
o url - URL to connect to the data base
o login - user login
o password - user password
Compilation:
------------
Set JOTM_HOME to the examples/jdbc-dist directory of your JOTM distribution (e.g.,
.../jotm/output/examples/jdbc-dist (JOTM_HOME/examples/jdbc-dist) from CVS)
Type
ant compile
to compile the example
------------------------------------------------------------------------------------
To run the example:
----------------
o To run the example, first check that only RMI protocol will be
activated (in the (JOTM_HOME/conf/carol.properties , carol.rmi.activated
should be set to jrmp); then type in $JOTM_HOME/lib/ directory
UNIX:
$ rmiregistry -J-classpath -Jjotm.jar:jotm_jrmp_stubs.jar -J-Djava.security.policy=../config/java.policy &
WINDOWS:
rmiregistry -J-classpath -Jjotm.jar;jotm_jrmp_stubs.jar;commons-cli-1.0.jar;connector-1_5.jar;howl.jar;mysql-connector-java-3.1.6-bin.jar -J-Djava.security.policy=../conf/java.policy
to start a RMI registry on default port (i.e. 1099).
---------------------------------------------------------------------------------------
o Setting the classpath
UNIX:
$ export CLASSPATH=../../lib/jotm.jar:../../lib/jotm_jrmp_stubs.jar:../../lib/xapool.jar:../../conf:../../lib/connector-1_5.jar:../../lib/howl.jar:../../lib/commons-cli-1.0.jar:../../lib/mysql-connector-java-3.1.7-bin.jar:.:../../conf/
WINDOWS:
set CLASSPATH=%CLASSPATH%;../../lib/jotm.jar;../../lib/jotm_jrmp_stubs.jar;../../lib/xapool.jar;../../lib/mysql-connector-java-3.1.7-bin.jar;../../lib/jdbc.jar;../../lib/connector-1_5.jar;../../lib/howl.jar;../../lib/commons-cli-1.0.jar;./;../../conf/
-------------------------------------------------------------------------------------------
o change mysql1.properties and mysql2.properties password/user to database user/password
o change mysql1.properties and mysql2.properties to reflect javatest1 and javatest2
--------------------------------------------------------------------------------------------
o Start the example
UNIX:
$ jave JdbcDistExample oracle1 oracle2 commit 4 // set table value to 4 and commit the transaction on Oracle &
$ java JdbcDistExample postgresql1 postgres2 commit 2 // set table value to 2 and commit the transaction on PostgreSQL &
$ java JdbcDistExample mysql1 mysql2 rollback 0 // set table value to 0 but rollback the transaction on MySQL &
$ java JdbcDistExample mysql1 mysql2 commit 2 &
$ java JdbcDistExample ...
WINDOWS:
jave JdbcDistExample oracle1 oracle2 commit 4 // set table value to 4 and commit the transaction on Oracle
java JdbcDistExample postgresql1 postgres2 commit 2 // set table value to 2 and commit the transaction on PostgreSQL
java JdbcDistExample mysql1 mysql2 rollback 0 // set table value to 0 but rollback the transaction on MySQL
java JdbcDistExample mysql1 mysql2 commit 0
java JdbcDistExample ...
o Of course you can mix databases
UNIX:
$ java JdbcDistExample oracle1 mysql1 rollback 0 & // set table value to 0 but rollback the transaction on MySQL
WINDOWS:
java JdbcDistExample oracle1 mysql1 rollback 0
Usage:
------
UNIX:
$ java JdbcExample [database1] [database2] [completion] [number] &
WINDOWS:
java JdbcExample [database1] [database2] [completion] [number]
where
o database can be:
- oracle
- postgresql
- mysql (example will look for a configuration file name [database].properties)
o completion can be:
- commit
- rollback
o number has to be a integer
Enjoy!
没有合适的资源?快使用搜索试试~ 我知道了~
开源分布式事务管理Jtom
共136个文件
java:66个
jar:17个
properties:14个
4星 · 超过85%的资源 需积分: 9 39 下载量 95 浏览量
2009-05-18
14:51:52
上传
评论
收藏 2.63MB RAR 举报
温馨提示
Jtom(java open Transaction Manager)是java写的事务管理器并实现了jta接口,而且是开源项目。
资源推荐
资源详情
资源评论
收起资源包目录
开源分布式事务管理Jtom (136个子文件)
.classpath 1KB
common.css 963B
doc2html 1KB
howto-integrate-jotm.html 14KB
howto-tomcat-jotm.html 11KB
JOTMArchitecture.html 9KB
package.html 157B
package.html 67B
package.html 58B
xerces.jar 1.53MB
joram.jar 760KB
log4j.jar 342KB
jeremie.jar 215KB
ow_carol.jar 180KB
jonathan-core.jar 154KB
jts1_0.jar 105KB
kilim.jar 100KB
howl.jar 98KB
xapool.jar 86KB
jonas_jms.jar 47KB
connector-1_5.jar 37KB
commons-logging.jar 31KB
commons-cli-1.0.jar 29KB
jms.jar 27KB
jta-spec1_0_1.jar 9KB
objectweb-datasource.jar 3KB
Current.java 69KB
SubCoordinator.java 57KB
ControlImpl.java 43KB
TransactionImpl.java 36KB
JotmRecovery.java 33KB
XidImpl.java 28KB
TransactionRecoveryImpl.java 26KB
JavaXidImpl.java 15KB
XATerminatorImpl.java 12KB
OTSInterceptor.java 11KB
Main.java 9KB
Jotm.java 9KB
TimerManager.java 8KB
OTSServerTransactionInterceptor.java 7KB
JdbcDistExample.java 7KB
JTAClientTransactionInterceptor.java 7KB
TSHandler.java 7KB
OTSClientTransactionInterceptor.java 7KB
SimpleJmsXa.java 7KB
JTAServerTransactionInterceptor.java 7KB
JdbcExample.java 6KB
DistDatabaseHelper.java 6KB
BasicExample.java 6KB
TransactionFactoryImpl.java 6KB
InternalTransactionContext.java 5KB
JTATransactionServiceContext.java 5KB
TimerEvent.java 5KB
TSHandlerFactory.java 5KB
TransactionRecovery.java 5KB
RmRegistration.java 5KB
DatabaseHelper.java 5KB
SimpleSender.java 4KB
DBTest.java 4KB
ResourceManagerEventListener.java 4KB
SimpleReceiver.java 4KB
TransactionContext.java 4KB
TransactionManager.java 4KB
TraceTimer.java 4KB
Coordinator.java 3KB
Log.java 3KB
JTAInterceptorInitializer.java 3KB
JotmTransactionReceiver.java 3KB
UserTransactionFactory.java 3KB
JotmTransactionSender.java 3KB
Resource.java 3KB
ResourceInfo.java 3KB
Terminator.java 3KB
TMService.java 3KB
ResourceManagerEvent.java 3KB
TraceTm.java 3KB
OTSORBInitializer.java 3KB
XAResourceHelper.java 3KB
Control.java 3KB
StatusHelper.java 3KB
HeuristicHazard.java 3KB
TransactionResourceManager.java 2KB
RemoteSynchro.java 2KB
TransactionFactory.java 2KB
HeuristicCommit.java 2KB
HeuristicMixed.java 2KB
NotPreparedException.java 2KB
InactiveException.java 2KB
HeuristicRollback.java 2KB
RecoveryCoordinator.java 2KB
Xid.java 2KB
TimerEventListener.java 2KB
test.jsp 714B
jotm.mf 268B
jotm.pdf 33KB
TXManagerRecoveryIssues.pdf 19KB
TXManagerRecoveryEvents.pdf 6KB
java.policy 319B
.project 380B
carol.properties 2KB
共 136 条
- 1
- 2
资源评论
- zengxx_0362012-11-20上当了,那只是源码而已
- wangyongxun19832014-03-07还可以挺好的 能锻炼自己的能力
- 不存在的卢比2014-02-17源码勉强还行
peispecial
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功