亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Spring+iBatis+Atomikos實現JTA事務

系統 2013 0

Atomikos分兩個:一個是開源的TransactionEssentials,一個是商業的ExtremeTransactions。
TransactionEssentials的主要特征:JTA/XA 事務管理 —— 提供事務管理和連接池不需要應用服務器 —— TransactionEssentials可以在任何Java EE應用服務器中運行,也就是不依賴于任何應用服務器開源 —— TransactionEssentials是遵守Apache版本2許可的開源軟件專注于JDBC/JMS —— 支持所有XA資源,但是資源池和消息監聽是專供JDBC和JMS的與Spring 和 Hibernate 集成 —— 提供了描述如何與Spring和Hibernate集成的文檔
一、環境

spring 2

ibatis2

AtomikosTransactionsEssentials-3.7.0?下載地址:http://www.atomikos.com/Main/InstallingTransactionsEssentials

MySQL-5.1 : 數據庫引擎為InnoDB,只有這樣才能支持事務?

JDK1.6

Oracle10


二 jar包

? Atomikos jar必須包?transactions-jdbc.jar

transactions-jta.jar

transactions.jar

atomikos-util.jar??

transactions-api.jar?

ibatis,spring

只要符合二者集成jar組合即可,無額外jar

三、配置

Oracle用戶授權:(視情況而定,如果程序出現如下異常則需要加上1672 [main] WARN atomikos - ERROR IN RECOVERY com.atomikos.datasource.ResourceException: Error in recovery)

grant select on sys.dba_pending_transactions to orcl;

grant select on sys.pending_trans$ to orcl;

grant select on sys.dba_2pc_pending to orcl;

grant execute on sys.dbms_system to orcl;


jta.properties 配置文件,即src/ jta.properties內容如下:

?

1 com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
2 ? com.atomikos.icatch.console_file_name = tm.out?
3 com.atomikos.icatch.log_base_name = tmlog?
4 com.atomikos.icatch.tm_unique_name = com.atomikos.spring.jdbc.tm?
5 com.atomikos.icatch.console_log_level = INFO

?

?


spring配置文件

代碼
        
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <? xml version="1.0" encoding="UTF-8" ?> < beans xmlns ="http://www.springframework.org/schema/beans" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop ="http://www.springframework.org/schema/aop" xmlns:tx ="http://www.springframework.org/schema/tx" xsi:schemaLocation ="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd " > <!-- 事物管理器 --> < bean id ="atomikosUserTransaction" class ="com.atomikos.icatch.jta.UserTransactionImp" > < description > UserTransactionImp </ description > < property name ="transactionTimeout" value ="300" /> </ bean > < bean id ="atomikosTransactionManager" class ="com.atomikos.icatch.jta.UserTransactionManager" init-method ="init" destroy-method ="close" > < description > UserTransactionManager </ description > < property name ="forceShutdown" > < value > true </ value > </ property > </ bean > < bean id ="transactionManager" class ="org.springframework.transaction.jta.JtaTransactionManager" > < description > JtaTransactionManager </ description > < property name ="transactionManager" > < ref bean ="atomikosTransactionManager" /> </ property > < property name ="userTransaction" > < ref bean ="atomikosUserTransaction" /> </ property > < property name ="allowCustomIsolationLevels" value ="true" /> <! —必須設置,否則程序出現異常 JtaTransactionManager does not support custom isolation levels by default -- > <! —oracle數據源定義 -- > </ bean > < bean id ="oracleDS" class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" > < description > oracle xa datasource </ description > < property name ="uniqueResourceName" > < value > oracle_ds </ value > </ property > < property name ="xaDataSourceClassName" > < value > oracle.jdbc.xa.client.OracleXADataSource </ value > </ property > < property name ="xaProperties" > < props > < prop key ="user" > orcl </ prop > < prop key ="password" > 123 </ prop > < prop key ="URL" > jdbc:oracle:thin:@ localhost:1521:orcl </ prop > </ props > </ property > < property name ="testQuery" > < value > select 1 from dual </ value > <! —盡力加上,不然會出現告警 -- > </ property > </ bean > <! — mysql數據源定義 -- > < bean id ="dataSourceoracle2" class ="com.atomikos.jdbc.AtomikosDataSourceBean" init-method ="init" destroy-method ="close" > < description > mysql xa datasource </ description > < property name ="uniqueResourceName" > < value > mysql_ds </ value > </ property > < property name ="xaDataSourceClassName" > < value > com.mysql.jdbc.jdbc2.optional.MysqlXADataSource </ value > </ property > < property name ="xaProperties" > < props > < prop key ="user" > root </ prop > < prop key ="password" > 123 </ prop > < prop key ="URL" > jdbc:mysql://localhost:3306/test?useUnicode=true &amp; characterEncoding=utf-8 </ prop > </ props > </ property > < property name ="testQuery" > < value > select 1 </ value > <! —盡力加上,不然會出現告警 -- > </ property > </ bean > <!-- ibatis配置源 --> < bean id ="sqlMapClient" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" > < property name ="configLocation" value ="classpath:sql-moredata-config.xml" /> < property name ="dataSource" ref ="oracleDS" /> </ bean > <!-- ibatis配置源2 --> < bean id ="sqlMapClient2" class ="org.springframework.orm.ibatis.SqlMapClientFactoryBean" > < property name ="configLocation" value ="classpath:sql-moredata2-config.xml" /> < property name ="dataSource" ref ="dataSourceoracle2" /> </ bean > < bean id ="testDaoR" class ="com.test.moredata.TestDAOImpR" > < property name ="sqlMapClient" ref ="sqlMapClient" ></ property > </ bean > < bean id ="testDao" class ="com.test.moredata.TestDAOImp" > < property name ="sqlMapClient" ref ="sqlMapClient2" ></ property > </ bean > < bean id ="testService" class ="com.test.moredata.TestService" > < property name ="testDao" ref ="testDao" ></ property > < property name ="testDaoR" ref ="testDaoR" ></ property > </ bean > <! — aop配置 -- > < tx:advice id ="transactionManagerAdivice" transaction-manager ="transactionManager" > < tx:attributes > < tx:method name ="*" isolation ="READ_COMMITTED" propagation ="REQUIRED" rollback-for ="java.lang.RuntionException" /> </ tx:attributes > </ tx:advice > < aop:config > < aop:pointcut expression ="execution(* com.test.moredata.TestService.*(..))" id ="tsServicePc" /> < aop:advisor advice-ref ="transactionManagerAdivice" pointcut-ref ="tsServicePc" /> </ aop:config >

Spring+iBatis+Atomikos實現JTA事務


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 999久久| 亚洲精品国产成人中文 | 亚洲春色综合另类网蜜桃 | 日韩视频免费在线播放 | 一区二区三区四区亚洲 | 野外一级毛片黑人 | 国产美女亚洲精品久久久久久 | 国产精品久久影院 | 不卡中文字幕在线观看 | 乱子伦xxxx厨房 | 草草国产成人免费视频 | 高清不卡一区二区三区 | 国产成人精品一区二三区2022 | 伊人五月天婷婷琪琪综合 | 欧美成人免费网在线观看 | 天天操夜夜操天天操 | 奇米777影视成人四色 | 久久99热这里只有精品免费看 | 亚洲综合精品一二三区在线 | 婷婷色网 | 99r视频里面只有精品 | 黄色在线免费观看 | 四虎影视在线影院4hu | 免费不卡 | 成人性色生活片免费网 | 国产小视频国产精品 | 国产精品无码久久av | 毛片a区| 亚洲一区二区在线成人 | 国产成人精品日本 | 俺来也欧美亚洲a∨在线 | 国产在线观看中文字幕 | 久久综合九九亚洲一区 | 免费一级a毛片在线播放视 免费一级成人毛片 | 久久精品国产欧美 | 精品久久伦理中文字幕 | 免费看真人a一级毛片 | 一级中国毛片 | 久久综合九色综合欧美狠狠 | 日韩一区二区三区免费视频 | 四虎色影院 |