很想采用opensourc的项目proxool来实现连接池。可它可真要我伤心的呀,测试了很久,也没有成功。不是说没有找到配置文件,就是说没有合适的驱动。真是晕,真是奇怪。我明明按照要求把配置文件和一直用的jdbc驱动程序放在了classpath下,可就是出现了问题,只能说明一点,那就是我还是没有明白它的原理。最后,找了很多的资料,终于测试成功了一种。
下面说明一下,在web application下用proxool来配置pool:
1)下载proxool类包
去http://proxool.sf.net/下最新的proxool。
2)把proxool类包,jdbc驱动程序放到WEB-INF/LIB下
3)添加连接信息的配置文件,并放入WEB-INF/LIB下,如protest.xml
<?
xml version="1.0" encoding="ISO-8859-1"
?>
<!--
the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored.
-->
<
something-else-entirely
>
<
proxool
>
<
alias
>
dglabour
</
alias
>
<
driver-url
>
jdbc:microsoft:sqlserver://192.168.1.35:1433;DatabaseName=dg_labour;SelectMethod=cursor;
</
driver-url
>
<
driver-class
>
com.microsoft.jdbc.sqlserver.SQLServerDriver
</
driver-class
>
<
driver-properties
>
<
property
name
="user"
value
="sa"
/>
<
property
name
="password"
value
="123"
/>
</
driver-properties
>
<
maximum-connection-count
>
10
</
maximum-connection-count
>
<
house-keeping-test-sql
>
select CURRENT_DATE
</
house-keeping-test-sql
>
</
proxool
>
</
something-else-entirely
>
4)在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/protest.xml
</
param-value
>
</
init-param
>
<
load-on-startup
>
1
</
load-on-startup
>
</
servlet
>
![None.gif](/Images/OutliningIndicators/None.gif)
<
servlet
>
<
servlet-name
>
Admin
</
servlet-name
>
<
servlet-class
>
org.logicalcobwebs.proxool.admin.servlet.AdminServlet
</
servlet-class
>
</
servlet
>
![None.gif](/Images/OutliningIndicators/None.gif)
<
servlet-mapping
>
<
servlet-name
>
Admin
</
servlet-name
>
<
url-pattern
>
/admin
</
url-pattern
>
</
servlet-mapping
>
5)在程序中用如下代码来调用,
connection
=
DriverManager.getConnection(
"
proxool.dglabour
"
);
6)测试页面
http://localhost:8080/shipment/admin shipment是web applicate名字
7)相关参考资料请看下载包中的文档,和 http://sentom.net/list.asp?id=33。
下面说明一下,在web application下用proxool来配置pool:
1)下载proxool类包
去http://proxool.sf.net/下最新的proxool。
2)把proxool类包,jdbc驱动程序放到WEB-INF/LIB下
3)添加连接信息的配置文件,并放入WEB-INF/LIB下,如protest.xml
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
4)在web.xml文件中添加如下代码
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
5)在程序中用如下代码来调用,
![None.gif](/Images/OutliningIndicators/None.gif)
http://localhost:8080/shipment/admin shipment是web applicate名字
7)相关参考资料请看下载包中的文档,和 http://sentom.net/list.asp?id=33。
![14.gif](/Emoticons/QQ/14.gif)