在applicationContext.xml同一级目录下新建一个proxoolconfig.xml
内容如下
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
<proxool>
<alias>proxoolPool</alias>
<!--proxool只能管理由自己产生的链接-->
<driver-url>jdbc:microsoft:sqlserver://localhost:1433</driver-url>
<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
<driver-properties>
<property name="user" value="sa"/>
<property name="password" value="sa"/>
</driver-properties>
<!-- proxool自动侦查各个链接状态的毫秒数,侦查到空闲的链接就马上回收,超时的销毁 -->
<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<!-- 当连接忙时等候的最大请求数,超过这个请求将不再接收-->
<maximum-new-connections>20</maximum-new-connections>
<!-- 最少保持的空闲连接数 -->
<prototype-count>5</prototype-count>
<!--最大连接数 -->
<maximum-connection-count>100</maximum-connection-count>
<!-- 最小连接数 -->
<minimum-connection-count>10</minimum-connection-count>
<!-- 自动重连 -->
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely>
2.在Application.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!--被屏蔽的这部分数据源可以不要,因为在proxool.xml中已经配置好了
<bean id="DataSourceId"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="url"
value="jdbc:microsoft:sqlserver://localhost:1433">
</property>
<property name="username" value="sa"></property>
<property name="password" value="sa"></property>
</bean>
-->
<bean id="SessionFactoryId"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!--<property name="dataSource">
<ref bean="DataSourceId" />
</property>
-->
<!-- 配置连接池 开始 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</prop>
<prop key="hibernate.proxool.xml">proxoolconf.xml</prop>
<!--注意下面的proxoolPool这个化名必须跟proxool.xml中的名字相同( <alias></alias>)-->
<prop key="hibernate.proxool.pool_alias">proxoolPool</prop>
</props>
</property>
<!-- 配置连接池 结束 -->
<property name="mappingResources">
<list>
<value>com/yang/dto/Users.hbm.xml</value></list>
</property></bean>
不知道我说的清不清楚,此列子希望能给初学者一些帮助。也希望大家能够提一些宝贵的建议