Spring下Proxool配置
使用spring2.5+ 及 proxool-0.9.1
web.xml配置如下:
<xml头>
<!--加载spring配置-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/**/*Context.xml
</param-value>
</context-param>
<!-- 配置监控路径 可以不要-->
<servlet>
<servlet-name>ProxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProxoolAdmin</servlet-name>
<url-pattern>/ProxoolAdmin.svl</url-pattern>
</servlet-mapping>
</xml>
applicationContext.xml配置如下:
<!-- 加载jdbc.properties配置文件-->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver" value="${db.driver}"/>
<property name="driverUrl" value="${db.url}"/>
<property name="user" value="${db.user}"/>
<property name="password" value="${db.password}"/>
<!--配置proxool参数-->
<property name="alias" value="${db.alias}"/>
<property name="simultaneousBuildThrottle" value="${db.simultaneousBuildThrottle}"/>
<property name="maximumActiveTime" value="${db.maximumActiveTime}"/>
<property name="houseKeepingTestSql" value="${db.houseKeepingTestSql}"/>
<property name="maximumConnectionCount" value="${db.maximumConnectionCount}"/>
<property name="minimumConnectionCount" value="${db.minimumConnectionCount}"/>
<property name="delegateProperties" value="characterEncoding=${db.characterEncoding}"/>
</bean>
jdbc.proprtity配置文件如下:
db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.url=jdbc:sqlserver://IP:1433;DatabaseName=databaseName
db.user=sa
db.password=sa
#为该连接池起一个别名,在其他文件中引用。引用是:(proxool.别名);
db.alias=dbpool
db.simultaneousBuildThrottle=500
db.maximumActiveTime = 3600000
db.houseKeepingTestSql=select 1
db.characterEncoding=GBK
#允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定
db.maximumConnectionCount=150
#最小连接数
db.minimumConnectionCount=30
使用jndi连接池
JNDI连接池,数据源已经由应用服务配置好需要做的只是通过JNDI名查找到此数据源。
<!--jdbc/db为数据源名称-->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/db"/>
</bean>
转http://www.cnblogs.com/aomo/archive/2011/11/24/2261890.html
使用spring2.5+ 及 proxool-0.9.1
web.xml配置如下:
<xml头>
<!--加载spring配置-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/**/*Context.xml
</param-value>
</context-param>
<!-- 配置监控路径 可以不要-->
<servlet>
<servlet-name>ProxoolAdmin</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProxoolAdmin</servlet-name>
<url-pattern>/ProxoolAdmin.svl</url-pattern>
</servlet-mapping>
</xml>
applicationContext.xml配置如下:
<!-- 加载jdbc.properties配置文件-->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver" value="${db.driver}"/>
<property name="driverUrl" value="${db.url}"/>
<property name="user" value="${db.user}"/>
<property name="password" value="${db.password}"/>
<!--配置proxool参数-->
<property name="alias" value="${db.alias}"/>
<property name="simultaneousBuildThrottle" value="${db.simultaneousBuildThrottle}"/>
<property name="maximumActiveTime" value="${db.maximumActiveTime}"/>
<property name="houseKeepingTestSql" value="${db.houseKeepingTestSql}"/>
<property name="maximumConnectionCount" value="${db.maximumConnectionCount}"/>
<property name="minimumConnectionCount" value="${db.minimumConnectionCount}"/>
<property name="delegateProperties" value="characterEncoding=${db.characterEncoding}"/>
</bean>
jdbc.proprtity配置文件如下:
db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.url=jdbc:sqlserver://IP:1433;DatabaseName=databaseName
db.user=sa
db.password=sa
#为该连接池起一个别名,在其他文件中引用。引用是:(proxool.别名);
db.alias=dbpool
db.simultaneousBuildThrottle=500
db.maximumActiveTime = 3600000
db.houseKeepingTestSql=select 1
db.characterEncoding=GBK
#允许最大连接数,超过了这个连接,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定
db.maximumConnectionCount=150
#最小连接数
db.minimumConnectionCount=30
使用jndi连接池
JNDI连接池,数据源已经由应用服务配置好需要做的只是通过JNDI名查找到此数据源。
<!--jdbc/db为数据源名称-->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/db"/>
</bean>
转http://www.cnblogs.com/aomo/archive/2011/11/24/2261890.html