Proxool连接池

Proxool连接池的使用心得2007-09-13 09:55   官方网址:http://proxool.sourceforge.net/     当前版本:proxool-0.9.0RC2

             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>Test</alias>
     <driver-url>jdbc:oracle:thin:@192.168.10.160:1521:orc1</driver-url>
     <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
     <driver-properties>
       <property name="user" value="test"/>
       <property name="password" value="testpass"/>
     </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>proxoolServletConfigurator</servlet-name>
     <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
      <init-param>
        <param-name>xmlFile</param-name>
        <param-value>WEB-INF/config/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


       以上配置是采用的XML文件方式,也可以采用properties配置方式:

proxool.alias=Test
proxool.driver-class=oracle.jdbc.driver.OracleDriver
proxool.driver-url=jdbc:oracle:thin:@192.168.10.160:1521:orcl
proxool.user=test
proxool.password=testpass
proxool.maximum-connection-count=20
proxool.prototype-count=4
proxool.house-keeping-test-sql=select sysdate from DUAL
proxool.verbose=true
proxool.statistics=10s,1m,1d
proxool.statistics-log-level=ERROR


<servlet>
<servlet-name>ServletConfigurator</servlet-name>
<servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>

<init-param>
    <param-name>propertyFile</param-name>
    <param-value>WEB-INF/config/Proxool.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


在调用数据库连接代码
    Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
    Connection conn = DriverManager.getConnection("proxool.Test");


还有一些配置属性:
maximum-connection-lifetime    最大连接生命周期 默认值:4小时
maximum-active-time:      最大活动时间    默认值:5分钟
maximum-connection-count    最大连接数     默认值:15个
minimum-connection-count    最小连接数     默认值:5个

在用admin调用的时候,可以查看这个WEB应用所有的连接数的状态,虽然这个插件可以把不活动的连接自动放到连接池里,但是如果连接数过多,而不及时KILL的话,对网站的连接是有很大的影响的,建议还是手工KILL。

、在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>
<proxool>
     <alias>Develop2</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="scmdob"/>
       <property name="password" value="scmdob"/>
     </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

你可能感兴趣的:(oracle,Web,xml,jdbc,配置管理)