proxool学习

使用连接池技术

1.jar

2.xml文件

<?xml version="1.0" encoding="UTF-8"?>


<something-else-entirely>
  <proxool>
    <alias>MyPool</alias>
    <driver-url>jdbc:mysql://localhost:3306/test</driver-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <driver-properties>
      <property name="user" value="root"/>
      <property name="password" value=""/>
    </driver-properties>
    <maximum-connection-count>30</maximum-connection-count>
    <minimum-connection-count>10</minimum-connection-count>
    <house-keeping-sleep-time>90000</house-keeping-sleep-time>
    <prototype-count>5</prototype-count>
    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
  </proxool>
</something-else-entirely>



3.修改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>



目录结构

proxool学习_第1张图片

思路:新建一个数据库properties文件,java端通过解析该文件连接数据库,web端访问  /admin 查看管理连接池



练习源码:http://download.csdn.net/detail/i_do_can/9372119


你可能感兴趣的:(proxool)