求助!!!玩过分布式数据库的专家,请指点数据库连接池的方法如何配置数据源
<?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" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:component-scan base-package="com.al.persistence.testcase.bmo.impl"/>
<!-- 第一个数据库 -->
<bean id="dataSource1" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="oracle1"/>
<property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<property name="xaProperties">
<props>
<prop key="user">sr</prop>
<prop key="password">sr</prop>
<prop key="URL">jdbc:oracle:thin:@192.168.74.15:1522:jttest</prop>
</props>
</property>
</bean>
<!-- 第二个数据库 -->
<bean id="dataSource2" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="oracle2"/>
<property name="xaDataSourceClassName" value="oracle.jdbc.xa.client.OracleXADataSource"/>
<property name="xaProperties">
<props>
<prop key="user">crm</prop>
<prop key="password">crm</prop>
<prop key="URL">jdbc:oracle:thin:@192.168.74.15:1522:jttest</prop>
</props>
</property>
</bean>
<!-- 持久层数据库操作主类 -->
<bean class="com.al.persistence.routing.RoutingSqlSessionFactoryBean">
<property name="targetDataSources">
<map>
<entry key="ds2" value-ref="dataSource2"/>
<entry key="ds1" value-ref="dataSource1"/>
</map>
</property>
<property name="strategy" value="com.al.persistence.testcase.routing.RoutingSessionStrategy"/><!-- 分库策略实现类 -->
<property name="configLocation" value="classpath:ibatis/configuration.xml"/>
</bean>
<bean class="com.al.persistence.ExtMapperScannerConfigurer">
<property name="basePackage" value="com.al.persistence.testcase.mapper"/>
</bean>
<!-- JTA事务 -->
<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close">
<property name="forceShutdown" value="true"/>
</bean>
<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="300"/>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager"/>
<property name="userTransaction" ref="atomikosUserTransaction"/>
</bean>
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* com.al.persistence.testcase.bmo.impl.*.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="insert*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="get*" read-only="true"/>
</tx:attributes>
</tx:advice>
</beans>以上是我的配置,网上找了半天没有找到在Spring配置分布式数据源atomikos包中用类似JNDI的配置方式。因为以下这种方式只要通过对应的中间件服务器(WAS或者WEBLOGIC里面数据库连接池配置)就可以不用在应用层面了解对应的用户名密码,生产系统客户可能3个月改一次密码,如果要通过每次改Spring里面配置的方式修改密码,问题很大,请各位涉及过这方面的高手大师能提供分布式数据库数据库连接池方式的配置方案。万分谢谢!
参考JNDI代码如下:
<!-- 配置JNDI -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${sr.jndiDataSource}"></property>
</bean>
...全文
相关推荐
ThinkPHP框架分布式数据库连接方法详解
主要介绍了ThinkPHP框架分布式数据库连接方法,结合实例形式详细分析了thinkPHP框架针对分布式数据库的连接方法、操作技巧与相关注意事项,需要的朋友可以参考下
java技术专家【分布式框架】ShardingSphere应用与实战教程(一)
java技术专家【分布式框架】ShardingSphere应用与实战教程(一)
SpringBoot整合Sharding-JDBC,实现从数据库加载sharding-jdbc数据源,实现多种数据库数据源切换,数据库方言动态切换
SpringBoot整合Sharding-JDBC,实现从数据库读取sharding-jdbc数据源,实现多种数据库数据源切换,数据库方言动态切换
Spring Boot+Jpa多数据源配置的完整步骤
主要给大家介绍了关于Spring Boot+Jpa多数据源配置的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
数据库连接池配置终极指南
数据库连接池配置终极指南,详细介绍了tomcat的部署流程


