Atomikos数据源配置方法有三种

 

 

http://kb.cnblogs.com/a/2012014/

Atomikos数据源配置方法有三种分别有:SimpleDataSourceBean,AtomikosDataSourceBean,AtomikosNonXADataSourceBean可任选一种

  
  
Simple表示基础数据库连接配置 < bean id ="oracleJta" class ="com.atomikos.jdbc.SimpleDataSourceBean" init-method ="init" destroy-method ="close" > < property name ="uniqueResourceName" > < value > OracleXADataSource </ value > <!-- 任意命名,但必须唯一 --> </ property > < property name ="xaDataSourceClassName" > < value > oracle.jdbc.xa.client.OracleXADataSource </ value > </ property > < property name ="xaDataSourceProperties" > < value > URL=jdbc:oracle:thin:@localhost:1521:orcl;user=orcl;password= </ value > </ property > < property name ="exclusiveConnectionMode" > < value > true </ value > </ property > < property name ="connectionPoolSize" > < value > 3 </ value > </ property > < property name ="validatingQuery" > < value > SELECT 1 </ value > </ property > </ bean > Atomikos表示必须要用到XA数据库驱动类,可设置连接池(经过测试推荐此方法) < bean id ="oracleJta" class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" lazy-init ="true" > < property name ="uniqueResourceName" > < value > OracleXADataSource </ value > </ property > < property name ="xaDataSourceClassName" > < value > oracle.jdbc.xa.client.OracleXADataSource </ value > </ property > < property name ="xaProperties" > < props > < prop key ="URL" > jdbc:oracle:thin:@localhost:1521:orcl </ prop > < prop key ="user" > orcl </ prop > < prop key ="password" ></ prop > </ props > </ property > < property name ="poolSize" >< value > 1 </ value ></ property > < property name ="maxPoolSize" >< value > 30 </ value ></ property > </ bean > AtomikosNon表示必须要用到普通数据库驱动类,可设置连接池 < bean id ="oracleJta" class ="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean" > < property name ="uniqueResourceName" >< value > OracleXADataSource </ value ></ property > < property name ="user" >< value > orcl </ value ></ property > < property name ="password" >< value ></ value ></ property > < property name ="url" >< value > jdbc:oracle:thin:@192.168.1.217:1521:orcl </ value ></ property > < property name ="driverClassName" >< value > oracle.jdbc.OracleDriver </ value ></ property > < property name ="poolSize" >< value > 1 </ value ></ property > < property name ="borrowConnectionTimeout" >< value > 60 </ value ></ property > </ bean > 另外一个数据库在这就不在写了,设置同上只是mysql的驱动类名为:xaDataSourceClassName:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

3.事务配置

  
  
Atomikos事务方法 < bean id ="atomikosTransactionManager" class ="com.atomikos.icatch.jta.UserTransactionManager" init-method ="init" destroy-method ="close" > < property name ="forceShutdown" > < value > true </ value > </ property > </ bean > < bean id ="atomikosUserTransaction" class ="com.atomikos.icatch.jta.UserTransactionImp" > < property name ="transactionTimeout" value ="240" /> </ bean > < bean id ="transactionManager" class ="org.springframework.transaction.jta.JtaTransactionManager" > < property name ="transactionManager" > < ref bean ="atomikosTransactionManager" /> </ property > < property name ="userTransaction" > < ref bean ="atomikosUserTransaction" /> </ property > </ bean > 接下来的代码和上例类同就不再写。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值