使用proxool配置多数据源

项目中同时访问oracle、mysql数据库,使用proxool配置多数据源,需要在dateSource的配置中设置别名 即<property name="alias" value="dateSource"/> 属性。如下配置:

<!-- Oracle configure -->
	<bean id="dateSource"
		 class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver">
			<value>${db.driverClass}</value>
		</property>
		<property name="driverUrl">
			<value><![CDATA[${db.jdbcUrl}]]></value>
		</property>
		<property name="user">
			<value>${db.user}</value>
		</property>
		 <property name="alias" value="dateSource"/> 
		<property name="password">
			<value>${db.password}</value>
		</property>
		<property name="maximumConnectionCount">
			<value>${db.maximumConnectionCount}</value>
		</property>
		<property name="minimumConnectionCount">
			<value>${db.minimumConnectionCount}</value>
		</property>
		<property name="houseKeepingTestSql">
			<value>${db.houseKeepingTestSql}</value>
		</property>
		<property name="testBeforeUse">
			<value>${db.testBeforeUse}</value>
		</property>
	</bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource">
			<ref local="dateSource"/>
		</property>
	</bean>

<!-- MySQL configure -->
	<bean id="mysqlDateSource"
		 class="org.logicalcobwebs.proxool.ProxoolDataSource">
		<property name="driver">
			<value>${db.mysql.driverClass}</value>
		</property>
		<property name="driverUrl">
			<value><![CDATA[${db.mysql.jdbcUrl}]]></value>
		</property>
				 <property name="alias" value="mysqlDateSource"/> 
		<property name="user">
			<value>${db.mysql.user}</value>
		</property>
		<property name="password">
			<value>${db.mysql.password}</value>
		</property>
		<property name="prototypeCount">
			<value>${db.mysql.prototypeCount}</value>
		</property>
		<property name="maximumConnectionCount">
			<value>${db.mysql.maximumConnectionCount}</value>
		</property>
		<property name="minimumConnectionCount">
			<value>${db.mysql.minimumConnectionCount}</value>
		</property>
		<property name="simultaneousBuildThrottle">
			<value>${db.mysql.simultaneousBuildThrottle}</value>
		</property>
		<property name="houseKeepingTestSql">
			<value>${db.mysql.houseKeepingTestSql}</value>
		</property>
		<property name="testBeforeUse">
			<value>${db.mysql.testBeforeUse}</value>
		</property>
	</bean>

	<bean id="mysqlJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource">
			<ref local="mysqlDateSource"/>
		</property>
	</bean>

 

你可能感兴趣的:(多数据源,proxool配置)