用proxool配置数据库连接池步骤
生活随笔
收集整理的這篇文章主要介紹了
用proxool配置数据库连接池步骤
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、下載proxool 地址:
http://proxool.sourceforge.net/download.html
??? 2、解壓縮proxool-0.9.0RC2.zip,拷貝lib/proxool-0.9.0RC2.jar到web-info/lib
??? ?? 拷貝jdbc驅(qū)動(dòng)到web-info/lib
??? 3、在web-info下建立文件:proxool.xml
???? 文件內(nèi)容如下:
<?xml?version="1.0"?encoding="ISO-8859-1"?>
<something-else-entirely>?
<proxool>????
????<alias>kc</alias>????
?????<driver-url>jdbc:microsoft:sqlserver://jifeng:1433;databasename=yao;</driver-url>?
????<!--<driver-url>jdbc:microsoft:sqlserver://localhost:1433;databasename=kc;</driver-url>-->
????<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>????
????<driver-properties>??????
????????<property?name="user"?value="sa"/>??????
????????<property?name="password"?value=""/>????
????</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文件內(nèi)加入以下內(nèi)容:
????<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>
<!-- proxool提供的管理監(jiān)控工具,可查看當(dāng)前數(shù)據(jù)庫(kù)連接情況。如果運(yùn)行不成功,請(qǐng)刪除本行 -->
? ????<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、在調(diào)用數(shù)據(jù)庫(kù)連接代碼:
import?java.sql.*;
import?javax.sql.*;
import?javax.naming.*;
import?org.logicalcobwebs.proxool.configuration.*;
public?class?Pool
...{
?????/**?*//**
?????*?得到數(shù)據(jù)庫(kù)的連接.
?????*?@throws?Exception?Pool:getConnection()--連接池獲得連接出錯(cuò)
?????*/
?????public?static?Connection?getConnection()?throws?Exception
????...{
????????//Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
????????//PropertyConfigurator.configure("proxool.properties");
????????//JAXPConfigurator.configure("proxool.xml",?false);?
????????try
????????...{
????????????Connection?conn?=?DriverManager.getConnection("proxool.kc");
????????????return?conn;
????????}
????????catch(Exception?e)
????????...{
????????????throw?new?Exception("Pool:getConnection()--連接池獲得連接出錯(cuò),請(qǐng)才web.xml文件中配置初始化參數(shù)。"+e.getMessage());
????????}????????
????}?
}
???? 6、利用proxool監(jiān)控工具查看數(shù)據(jù)庫(kù)運(yùn)行狀態(tài)。地址:./admin
??? 2、解壓縮proxool-0.9.0RC2.zip,拷貝lib/proxool-0.9.0RC2.jar到web-info/lib
??? ?? 拷貝jdbc驅(qū)動(dòng)到web-info/lib
??? 3、在web-info下建立文件:proxool.xml
???? 文件內(nèi)容如下:
<?xml?version="1.0"?encoding="ISO-8859-1"?>
<something-else-entirely>?
<proxool>????
????<alias>kc</alias>????
?????<driver-url>jdbc:microsoft:sqlserver://jifeng:1433;databasename=yao;</driver-url>?
????<!--<driver-url>jdbc:microsoft:sqlserver://localhost:1433;databasename=kc;</driver-url>-->
????<driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>????
????<driver-properties>??????
????????<property?name="user"?value="sa"/>??????
????????<property?name="password"?value=""/>????
????</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文件內(nèi)加入以下內(nèi)容:
????<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>
<!-- proxool提供的管理監(jiān)控工具,可查看當(dāng)前數(shù)據(jù)庫(kù)連接情況。如果運(yùn)行不成功,請(qǐng)刪除本行 -->
? ????<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、在調(diào)用數(shù)據(jù)庫(kù)連接代碼:
import?java.sql.*;
import?javax.sql.*;
import?javax.naming.*;
import?org.logicalcobwebs.proxool.configuration.*;
public?class?Pool
...{
?????/**?*//**
?????*?得到數(shù)據(jù)庫(kù)的連接.
?????*?@throws?Exception?Pool:getConnection()--連接池獲得連接出錯(cuò)
?????*/
?????public?static?Connection?getConnection()?throws?Exception
????...{
????????//Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
????????//PropertyConfigurator.configure("proxool.properties");
????????//JAXPConfigurator.configure("proxool.xml",?false);?
????????try
????????...{
????????????Connection?conn?=?DriverManager.getConnection("proxool.kc");
????????????return?conn;
????????}
????????catch(Exception?e)
????????...{
????????????throw?new?Exception("Pool:getConnection()--連接池獲得連接出錯(cuò),請(qǐng)才web.xml文件中配置初始化參數(shù)。"+e.getMessage());
????????}????????
????}?
}
???? 6、利用proxool監(jiān)控工具查看數(shù)據(jù)庫(kù)運(yùn)行狀態(tài)。地址:./admin
總結(jié)
以上是生活随笔為你收集整理的用proxool配置数据库连接池步骤的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 2006年中国软件收入规模前100家企业
- 下一篇: BIRT:基于 Eclipse 的报表