今天一天就做着搞proxool的配置问题,通过多方面的查询终于配置成功,所以写了这篇文章以便后面工作的查询
1、配置proxool必需的有两个包proxool-0.9.1.jar跟proxool-cglib.jar
2、配置proxool.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- the proxool configuration can be embedded within your own application's. Anything outside the "proxool" tag is ignored. --> <something-else-entirely> <proxool> <alias>printer</alias> <!--数据源的别名 --> <driver-url>jdbc:oracle:thin:@localhost:1521:orcl</driver-url><!--url连接串 --> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <!--驱动类 --> <driver-properties> <property name="user" value="zy" /> <!--用户名 --> <property name="password" value="zy" /><!--密码 --> </driver-properties> <!--最大连接数(默认5个),超过了这个连接数,再有请求时,就排在队列中等候,最大的等待请求数由maximum-new-connections决定 --> <maximum-connection-count>100</maximum-connection-count> <!--最小连接数(默认2个) --> <minimum-connection-count>10</minimum-connection-count> <!--proxool自动侦察各个连接状态的时间间隔(毫秒),侦察到空闲的连接就马上回收,超时的销毁 默认30秒 --> <house-keeping-sleep-time>90000</house-keeping-sleep-time> <!--没有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的用户连接就不会被接受 --> <maximum-new-connections>10</maximum-new-connections> <!--最少保持的空闲连接数(默认2个) --> <prototype-count>5</prototype-count> <!--在使用之前测试 --> <test-before-use>true</test-before-use> <!--用于保持连接的测试语句 --> <house-keeping-test-sql>select sysdate from dual </house-keeping-test-sql> </proxool> </something-else-entirely>
3、配置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" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd" default-autowire="byType"> <!-- 支持元注释 --> <context:annotation-config></context:annotation-config> <context:component-scan base-package="com.scan918.printerordersystem"></context:component-scan> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" destroy-method="close"> <property name="hibernateProperties"> <props> <!-- 使用proxool配置类型 --> <prop key="hibernate.connection.provider_class"> org.hibernate.connection.ProxoolConnectionProvider </prop> <!-- proxool配置文件,注意路径 --> <prop key="hibernate.proxool.xml">proxool.xml</prop> <prop key="hibernate.proxool.pool_alias"> printer </prop> <prop key="hibernate.dialect"> org.hibernate.dialect.OracleDialect </prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> <property name="mappingResources"> <list> <value> com/scan918/printerordersystem/model/Orderstate.hbm.xml </value> </list> </property> </bean> </beans>