Spring、proxool和tomcat Jndi方式整合

时间:2022-12-30 19:10:40

整合配置代码清单说明

   1、tomcat的context.xml的配置

<Context>

<Resource name="jdbc/mysql"
     auth="Container"   
     type="javax.sql.DataSource"
     factory="org.logicalcobwebs.proxool.ProxoolDataSource"   
     proxool.alias="testDB"   
     user="root" 
     password="kingsoft"   
     delegateProperties="foo=1,bar=true"
     proxool.jndi-name="mysqljndi"  
     proxool.driver-url="jdbc:mysql://127.0.0.1:3306/sampledb"   
     proxool.driver-class="com.mysql.jdbc.Driver" 
     proxool.house-keeping-sleep-time="900000" 
     proxool.maximum-active-time="5"
     proxool.prototype-count="3"
     proxool.statistics="1m,15m,1d"
     proxool.simultaneous-build-throttle="10"
     proxool.minimum-connection-count="5"
     proxool.maximum-connection-count="15"
     proxool.house-keeping-test-sql="select CURRENT_DATE from dual"
     proxool.test-before-use="true"/>
</Context>

   2、spring的配置文件

    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/mysql"/>
 </bean>