站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题使用xml文件为mysql数据库配连接池proxool

使用xml文件为mysql数据库配连接池proxool

摘要: 使用xml文件为mysql数据库配连接池proxool

</td> </tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> 1、先写xml文件:Proxool.xml放入你的WEB应用程序的WEB-INF\classes下面,内容如下:

<?xml version="1.0" encoding="ISO-8859-1"?>
Anything outside the "proxool" tag is ignored.
<table width="681" border="0"> <tr> <td width="399">


xml-test
jdbc:mysql://localhost:3306/soft
org.gjt.mm.mysql.Driver




10
select CURRENT_DATE





</td> <td width="272"> </td> </tr> </table>

2、web.xml如是写:

<?xml version="1.0" encoding="ISO-8859-1"?>
web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">



ServletConfigurator


org.logicalcobwebs.proxool.configuration.ServletConfigurator


xmlFile
WEB-INF/classes/Proxool.xml

1



Admin
org.logicalcobwebs.proxool.admin.servlet.AdminServlet



Admin
/Admin





3、将驱动程序mm.mysql-2.0.14-bin.jar与proxool-0.8.3.jar及crimson.jar放入WEB-INF\lib目录下。
4、测试的jsp文件:
<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=GB2312" %>


<head>
CH14 - Proxool.jsp
</head>
<body>

使用 Proxool Connection Pool,用xml文件配置



<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try{
con = DriverManager.getConnection("proxool.xml-test");
stmt = con.createStatement();
String query = "select * from count_num";
rs = stmt.executeQuery(query);

while(rs.next()) {
out.print(rs.getLong(1)+"--OK");
}

stmt.close();
con.close();
}catch(SQLException sqle){
out.println("sqle="+sqle);
}
finally{
try {
if(con != null){
con.close();
}
}catch(SQLException sqle){
out.println("sqle="+sqle);
}
}

%>

</body>


5、后台统计与信息

请进入:http://127.0.0.1:8080/testpxool1/Admin
(testpxool1应改为你的WEB应用程序名)</td> </tr> <tr>


↑返回目录
前一篇: Log4j日志管理系统简单使用说明
后一篇: 使用属性文件为mysql数据库配连接池proxool