配置一:XML方法
1、下载proxool 地址:http://proxool.sourceforge.net
2、解压缩proxool-0.9.0RC2.zip,拷贝lib/proxool-0.9.0RC2.jar到web-info/lib
拷贝jdbc驱动到web-info/lib
3、在web-info下建立文件:proxool.xml
文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
<proxool>
<alias>Develop</alias>
<driver-url>jdbc:oracle:thin:@192.168.100.18:1521:RNMS</driver-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver-properties>
<property name="user" value="scmlp"/>
<property name="password" value="scmlpscmlp"/>
</driver-properties>
<maximum-connection-count>500</maximum-connection-count>
<house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
</proxool>
</something-else-entirely>
4、在web.xml文件内加入以下内容:
<servlet>
<servlet-name>proxoolServletConfigurator</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>
<!-- proxool提供的管理监控工具,可查看当前数据库连接情况。如果运行不成功,请删除本行 -->
<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>
5、在调用数据库连接代码:
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
Connection conn = DriverManager.getConnection("proxool.Develop");
6、利用proxool监控工具查看数据库运行状态。地址:./admin
配置二:properties方法
1,下载proxool-0.8.3.jar并放到相应的目录,这个应该比较简单了
2,写一个配置文件放到web-inf目录下,配置文件内容如下:
jdbc-0.proxool.alias=bidding
jdbc-0.proxool.driver-url=jjdbc:oracle:thin:@127.0.0.1:1521:dbname
jdbc-0.proxool.driver-class=oracle.jdbc.driver.oracledriver
jdbc-0.user=name
jdbc-0.password=pass
jdbc-0.proxool.maximum-connection-count=200
jdbc-0.proxool.house-keeping-test-sql=select *
3,在web-inf/web.xml中添加如下代码:
<servlet>
<servlet-name>servletconfigurator</servlet-name>
<servlet-lass>org.logicalcobwebs.proxool.configuration.servletconfigurator</servlet-class>
<init-param>
<param-name>propertyfile</param-name>
<param-value>web-inf/proxool.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
4,配置就这么简单,下面给你一段怎么得到一个连接代码,其他的应该就比较简单了
public connection getconnection() {
try {
conn = drivermanager.getconnection("proxool.bidding");
}catch(sqlexception ex){
ex.printstacktrace();
} finally {
try {
if (conn != null) {
conn.close();
}
} catch (sqlexception e) {
e.printstacktrace();
log("problem closing connection");
}
}
return conn;
}