现在需要配置两个datasource,两个库交互的时候,想用jta解决全局事务的问题,
在网上找了相关的资料,大多数都是jdbc的,
我想用proxool.也有不过都是jotm的,有人知道纯jta的吗?
为此求助!!希望可以提供相关的配置资料!先谢啦!!
在网上找了相关的资料,大多数都是jdbc的,
我想用proxool.也有不过都是jotm的,有人知道纯jta的吗?
为此求助!!希望可以提供相关的配置资料!先谢啦!!
解决方案 »
- Struts 2 + <jsp:useBean> 无法显示值。很急!!!!!
- EJB QL的查询问题
- 请做过这Struts+Spring+Hibernate三者结合教程的大侠进来看看,谢谢!
- 麻烦看一下:datasource初始化错误,jndi配置问题
- tomcat安装成功以后如何加入新的jsp文件?
- 开发JAVA一般用什么LINUX系统?用什么版本?
- !!!!请看看这个异常:weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync=weblogic.ejb20.intern
- 关于rmi在jb里面的问题
- mysql7.5.9安装时报"缺少python27.dll"的错怎么搞?
- 怎么根据不同的部门显示相对应的员工?SQL语句要怎么写呢?J2EE,采用MVC架构
- 急:java 在调用Delphi写的WebService时,生成客户端代码时出错
- 一个Bug搞了一晚,大家帮帮忙
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" /> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction">
<ref local="jotm" />
</property>
</bean>
<bean id="innerMysqlDataSource" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="driverName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://xxxxxxxxxxxxxxx</value>
</property>
</bean> <bean id="dataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<property name="dataSource">
<ref local="innerMysqlDataSource" />
</property>
<property name="maxSize">
<value>5</value>
</property>
<property name="minSize">
<value>2</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean> <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>org/sh/model/People.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property> </bean>
<bean id="innerMysqlDataSource2" class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transactionManager">
<ref local="jotm" />
</property>
<property name="driverName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://xxxxxxxxxxxxxxx</value>
</property>
</bean> <bean id="dataSource2" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<property name="dataSource">
<ref local="innerMysqlDataSource2" />
</property>
<property name="maxSize">
<value>5</value>
</property>
<property name="minSize">
<value>2</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="mySessionFactory2" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="mappingResources">
<list>
<value>org/sh/model/People.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="jtaTransactionManager">
<ref bean="jotm" />
</property> </bean>
<!-- 事务拦截 开始-->
<bean id="beanNameProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*DS</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
<bean id="transactionInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributeSource"
ref="txAttributeSource" />
</bean>
<bean id="txAttributeSource"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
</props>
</property>
</bean>
<!-- 事务拦截 结束-->
<bean id="PeopleDS" class="org.sh.service.PeopleDS">
<property name="dao">
<bean class="org.sh.dao.PeopleDAO">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
</property>
</bean>
</beans>
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>classpath*:beanRefContext.xml</param-value>
</context-param>
<context-param>
<param-name>parentContextKey</param-name>
<param-value>beangroup</param-value>
</context-param>
<!--指明父亲applicationContext,end -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
applicationContext.xml<!-- XAPool配置,内部包含了一个XA数据源 -->
<bean id="applyDataSource" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
<property name="dataSource">
<!-- 内部XA数据源 -->
<bean class="org.enhydra.jdbc.standard.StandardXADataSource" destroy-method="shutdown">
<property name="transactionManager">
<ref bean="jotm"/>
</property>
<property name="driverName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@00.0.00.0:1521:db</value>
</property>
</bean>
</property>
<property name="user">
<value>user</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean> <bean id="applySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingLocations">
<list>
<value>classpath:/bo/*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
<property name="lobHandler">
<ref bean="lobHandler"/>
</property>
<property name="dataSource">
<ref bean="applyDataSource"/>
</property>
</bean>
<!-- ========================= Start of SERVICE DEFINITIONS ========================= -->
<bean id="applyDAO" class=".dao.impl.ApplyDAOImpl">
<property name="sessionFactory">
<ref bean="applySessionFactory"/>
</property>
</bean>
<bean id="applyService" class="service.impl.ApplyServiceImpl">
<!-- 应用的dao -->
<property name="applyDAO">
<ref bean="applyDAO" />
</property>
</bean>
<bean id="processUCCTarget" class="impl.ProcessUCCImpl">
<!-- 引擎的service -->
<property name="processService">
<ref bean="processService" />
</property>
<!-- 应用的service -->
<property name="applyService">
<ref bean="applyService" />
</property>
</bean>
<bean id="processUCC" parent="baseTransactionProxy">
<property name="proxyInterfaces">
<list>
<value>ucc.IProcessUCC</value>
</list>
</property>
<property name="target">
<ref bean="processUCCTarget"/>
</property>
</bean>
beanRefContext.xml
<beans>
<bean id="beangroup" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>proContext.xml</value>
</list>
</constructor-arg>
</bean>
</beans>proContext.xml<beans>
<!--
========================= Start of PERSISTENCE DEFINITIONS
=========================
--> <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="processDataSource" />
</property>
</bean> <bean id="namingTransactionAttribute"
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="del*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean> <bean id="baseTransactionProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionAttributeSource">
<ref bean="namingTransactionAttribute" />
</property>
</bean> <bean id="processDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@00.0.000.1:1521:db</value>
</property> <property name="user">
<value>user</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean> <bean id="nativeJdbcExtractor"
class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
<bean id="lobHandler" lazy-init="true"
class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor">
<ref bean="nativeJdbcExtractor" />
</property>
</bean> <!-- Hibernate SessionFactory Definition --> <bean id="processSessionFactory1"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingLocations">
<list>
<value>cn/ccb/common/model/bo/BMFlowList.hbm.xml</value>
<value>cn/ccb/common/model/bo/BMTaskInfo.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_outer_join">true</prop>
<prop key="hibernate.max_fetch_depth">1</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
<property name="lobHandler">
<ref bean="lobHandler" />
</property>
<property name="dataSource">
<ref bean="processDataSource" />
</property>
</bean> <!--
========================= Start of SERVICE DEFINITIONS
=========================
--> <bean id="processDAO" class="dao.impl.ProcessDAOImpl">
<property name="sessionFactory">
<ref bean="processSessionFactory1" />
</property>
</bean> <bean id="processService" class="service.impl.ProcessServiceImpl">
<!-- 引擎的dao -->
<property name="processDAO">
<ref bean="processDAO" />
</property>
</bean>
</beans>