proxool连接池的配置(0.8.3)
1. 配置文件(xml形式,文件名任意)
--------------------------------
<?xml version="1.0"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
<proxool>
<alias>mypool</alias> <!-- add "proxool" before alias -- proxool.alias -->
<driver-url>jdbc:oracle:thin:@localhost:1521:oradb</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="username"/>
<property name="password" value="password"/>
</driver-properties>
<connection-lifetime>60</connection-lifetime>
<maximum-connection-count>50</maximum-connection-count>
<minimum-connection-count>4</minimum-connection-count>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely>
2.web.xml配置
--------------
<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>
<!-- monitor proxool status -->
<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>
3. 程序调用
Connection conn=null;
try {
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
conn = DriverManager.getConnection("proxool.mypool"); //add "proxool" before "mypool" in proxool.xml
}catch(ClassNotFountException e){
e.printStackTrace();
}catch(SQLException e) {
e.printStackTrace();
}