MYSQL连接池

mysql 数据库连接池亲身经验:

准备文件:

mysql-connector-java-5.0.3-bin.jar

proxool-0.9.0RC3.jar

在web.xml里添加:
 1    < servlet >
 2    < servlet - name > ServletConfigurator </ servlet - name >
 3    < servlet - class > org.logicalcobwebs.proxool.configuration.ServletConfigurator </ servlet - class >
 4    < init - param >
 5      < param - name > xmlFile </ param - name >
 6      < param - value > WEB - INF / db.xml </ param - value >
 7    </ init - param >
 8    < load - on - startup > 1 </ load - on - startup >
 9 </ servlet >
10
11 < servlet >
12    < servlet - name > proxool </ servlet - name >
13    < servlet - class > org.logicalcobwebs.proxool.admin.servlet.AdminServlet </ servlet - class >
14 </ servlet >
15
16 < servlet - mapping >
17    < servlet - name > proxool </ servlet - name >
18    < url - pattern >/ Admin </ url - pattern >
19 </ servlet - mapping >  

db.xml


<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> 1<?xml version="1.0" encoding="UTF-8" ?>
 2<proxool>
 3<alias>pmd</alias>
 4<driver-url>jdbc:mysql://192.168.1.200:3306/pmdl1</driver-url>
 5<driver-class>org.gjt.mm.mysql.Driver</driver-class>
 6<statistics>1m,15m,1d</statistics>
 7<driver-properties>
 8<property name="user" value="root"/>
 9<property name="password" value="dfxs$"/>
10<property name="characterEncoding" value="UTF-8"/>
11<property name="useUnicode" value="true"/>
12</driver-properties>
13<house-keeping-sleep-time>90000</house-keeping-sleep-time> 
14<prototype-count>5</prototype-count> 
15<maximum-connection-count>100</maximum-connection-count>
16<minimum-connection-count>10</minimum-connection-count>
17<maximum-active-time>60000</maximum-active-time>
18</proxool>

含义很明了。不用多说。

在实际试用中,如正常试用mysql链接一样。

比如在jsp中添加:
<%@ page import="java.sql.*" %>
<%@ page import="org.logicalcobwebs.proxool.*" %>
<%@ page import="org.logicalcobwebs.proxool.configuration.*" %>

然后:
Connection conn = null;      
      try {
         // PropertyConfigurator.configure("Proxool.properties");
          conn = DriverManager.getConnection("proxool. test");

……
test是 配置文件中的别名。


你可能感兴趣的:(Web,xml,mysql,servlet,prototype)