#
#
# 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!
没有合适的资源?快使用搜索试试~ 我知道了~
spring-hibernate-jotm 例子
共230个文件
html:143个
java:18个
jar:17个
5星 · 超过95%的资源 需积分: 10 89 下载量 25 浏览量
2010-02-13
08:05:11
上传
评论 1
收藏 2.52MB RAR 举报
温馨提示
内含jotm文件,使用时需要将spring和hibernate的jar包河jotm的jar包全部导入到工程中
资源推荐
资源详情
资源评论
收起资源包目录
spring-hibernate-jotm 例子 (230个子文件)
UserDAOAHibernateImpl.class 2KB
UserDAOHibernateImpl.class 2KB
RegisterServiceSpringImpl.class 2KB
User.class 1KB
Client.class 977B
UserDAOA.class 446B
UserDAO.class 444B
RegisterService.class 329B
TestException.class 295B
.classpath 4KB
stylesheet.css 1KB
common.css 963B
inherit.gif 57B
index-all.html 139KB
Current.html 80KB
TransactionImpl.html 46KB
ControlImpl.html 37KB
TransactionRecoveryImpl.html 33KB
OTSServerTransactionInterceptor.html 29KB
OTSClientTransactionInterceptor.html 29KB
XidImpl.html 27KB
SubCoordinator.html 26KB
InternalTransactionContext.html 24KB
XATerminatorImpl.html 24KB
OTSInterceptor.html 23KB
TransactionContext.html 22KB
overview-tree.html 22KB
serialized-form.html 22KB
TransactionRecovery.html 21KB
OTSORBInitializer.html 21KB
JTAClientTransactionInterceptor.html 21KB
JavaXidImpl.html 20KB
Main.html 19KB
TransactionFactoryImpl.html 19KB
JTAServerTransactionInterceptor.html 19KB
TraceTimer.html 19KB
JTATransactionServiceContext.html 19KB
Jotm.html 18KB
RmRegistration.html 18KB
TSHandler.html 18KB
JotmRecovery.html 17KB
package-tree.html 17KB
TSHandlerFactory.html 17KB
TimerEvent.html 17KB
package-summary.html 17KB
TimerManager.html 16KB
HeuristicMixed.html 16KB
InactiveException.html 16KB
HeuristicRollback.html 16KB
HeuristicHazard.html 16KB
TransactionContext.html 16KB
NotPreparedException.html 16KB
HeuristicCommit.html 16KB
Coordinator.html 15KB
TransactionManager.html 15KB
package-use.html 15KB
Resource.html 15KB
howto-integrate-jotm.html 14KB
Coordinator.html 14KB
UserTransactionFactory.html 14KB
JTAInterceptorInitializer.html 14KB
TraceTm.html 14KB
Xid.html 13KB
JotmTransactionSender.html 13KB
ResourceManagerEventListener.html 13KB
JotmTransactionReceiver.html 13KB
Terminator.html 13KB
ResourceManagerEvent.html 12KB
Control.html 12KB
TransactionFactory.html 12KB
TransactionResourceManager.html 12KB
Xid.html 12KB
XAResourceHelper.html 12KB
TMService.html 11KB
howto-tomcat-jotm.html 11KB
TransactionManager.html 11KB
TransactionRecovery.html 11KB
Resource.html 10KB
constant-values.html 10KB
Terminator.html 10KB
TimerEventListener.html 10KB
RemoteSynchro.html 10KB
Control.html 10KB
package-use.html 10KB
ResourceManagerEventListener.html 10KB
ResourceManagerEvent.html 10KB
RecoveryCoordinator.html 9KB
TimerEvent.html 9KB
TransactionResourceManager.html 9KB
TransactionFactory.html 9KB
RecoveryCoordinator.html 9KB
JOTMArchitecture.html 9KB
help-doc.html 9KB
TimerEventListener.html 9KB
JotmRecovery.html 8KB
allclasses-frame.html 8KB
OTSInterceptor.html 8KB
RemoteSynchro.html 8KB
package-summary.html 8KB
package-summary.html 8KB
共 230 条
- 1
- 2
- 3
jack_wolf_xian
- 粉丝: 4
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Pytorch复现Point-Transformer,用于ShapeNet数据集点云分割
- 【医学影像分析】2D超声图像的分割检测(Ultrasound Nerve Segmentation - Kaggle数据集)
- 嘎嘎香的五款神仙谷歌插件
- .arch书源导入教程.mp4
- 贪心算法介绍及代码示例讲解
- CR13SP35MSI64 Crystal 水晶报表运行组件最后版本64位
- 图像分类数据集:玉米叶是否感染分类数据集(2分类,包含训练集、验证集)
- 小U商城.zip
- 高光谱图像计算机视觉分类图像预处理工具集,包含去除图片无关背景,数据增强,生成标签文件等功能
- (顶刊复现)基于配电网韧性提升的应急移动电源预配置和动态调度(下)-MPS动态调度
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页