<?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>dbname</alias> <!--数据源的别名--> <driver-url>jdbc:oracle:thin:@127.0.0.1:1521:testdb</driver-url><!--url连接串--> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <!--驱动类--> <driver-properties> <property name="user" value="username" /> <!--用户名--> <property name="password" value="password" /><!--密码--> </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>
proxool.xml文件,加入相应扎包。
以下在web.xml中配置
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>ServletConfigurator</servlet-name> <servlet-class> org.logicalcobwebs.proxool.configuration.ServletConfigurator </servlet-class> <init-param> <param-name>xmlFile</param-name> <param-value>WEB-INF/proxool.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>Admin</servlet-name> <servlet-class> org.logicalcobwebs.proxool.admin.servlet.AdminServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>Admin</servlet-name> <url-pattern>/admin</url-pattern> </servlet-mapping> <!-- 配置受保护域,只有Tomcat管理员才能察看连接池的信息 --> <security-constraint> <web-resource-collection> <web-resource-name>proxool</web-resource-name> <url-pattern>/admin</url-pattern> </web-resource-collection> <auth-constraint> <role-name>manager</role-name> </auth-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>proxool manager Application</realm-name> </login-config> <security-role> <description>The role that is required to log in to the Manager Application</description> <role-name>manager</role-name> </security-role> <error-page> <error-code>401</error-code> <location>/401.jsp</location> </error-page> </web-app>
转自:http://sunnylocus.iteye.com/blog/359570