配置文件如下:
<?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:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="DBpool" class="org.logicalcobwebs.proxool.ProxoolDataSource"> <property name="driver" value="oracle.jdbc.driver.OracleDriver"/> <property name="driverUrl" value="jdbc:oracle:thin:@192.168.200.8:1521:orcl"/> <property name="user" value="jck"/> <property name="password" value="jck"/> <property name="houseKeepingTestSql" value="select 1 from dual"/> <property name="simultaneousBuildThrottle" value="100"/> <property name="prototypeCount" value="5"/> <property name="maximumActiveTime" value="1800000"/> <property name="maximumConnectionCount" value="20"/> <property name="minimumConnectionCount" value="1"/> </bean> <bean id="LWPool" class="org.logicalcobwebs.proxool.ProxoolDataSource"> <property name="driver" value="oracle.jdbc.driver.OracleDriver"/> <property name="driverUrl" value="jdbc:oracle:thin:@192.168.200.8:1521:orcl"/> <property name="user" value="lwisp"/> <property name="password" value="lwisp"/> <property name="houseKeepingTestSql" value="select 1 from dual"/> <property name="simultaneousBuildThrottle" value="100"/> <property name="prototypeCount" value="5"/> <property name="maximumActiveTime" value="1800000"/> <property name="maximumConnectionCount" value="20"/> <property name="minimumConnectionCount" value="1"/> </bean> <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"> <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" /> </bean> <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" /> </beans>
获取数据源的方式:
如果用 ProxoolDataSource类来获取conn对象 不行
ProxoolDataSource pxDs = (ProxoolDataSource) applicationContext.getBean("LWPool");
可以要用 DataSource ds = (DataSource)applicationContext.getBean("LWPool");
xml文件要增加下面的属性
<property name="alias" value="proxool.a2"/>
也就可以了