浏览 4416 次
锁定老帖子 主题:proxool难搞的问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-03-01
用proxool的propeties方法,设置数据库连接,总是出错: org.logicalcobwebs.proxool.ProxoolException: Couldn't load property file hsqldb.properties 以下是我的代码: 1. hsqldb.properties jdbc-0.proxool.alias=hsqldb jdbc-0.proxool.driver-class=oracle.jdbc.driver.OracleDriver jdbc-0.proxool.driver-url=jdbc:oracle:thin:@192.168.1.61:1521:ORCL jdbc-0.user=xxxx jdbc-0.password=xxxxxxx jdbc-0.proxool.maximum-connection-count=20 jdbc-0.proxool.prototype-count=4 jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE jdbc-0.proxool.verbose=true jdbc-0.proxool.statistics=10s,1m,1d jdbc-0.proxool.statistics-log-level=ERROR 放在与WEB-INF相同的一个file目录里,发布时可以直接映射到webapp/web-inf/classes下面.<服务器tomcat> 2. web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <servlet-name>proxoolServletConfigurator</servlet-name> <servlet-class> org.logicalcobwebs.proxool.configuration.ServletConfigurator </servlet-class> <init-param> <param-name>propertyFile</param-name> <param-value>WEB-INF/classes/hsqldb.properties</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> </web-app> 3. 测试类DBTest.java import java.sql.*; import org.logicalcobwebs.proxool.configuration.PropertyConfigurator; import org.logicalcobwebs.proxool.ProxoolException; public class DBTest { public static void main(String[] args) { String db = "hsqldb"; if(args.length > 0 ) { db = args[0]; } Connection conn=null; try { PropertyConfigurator.configure(db + ".properties"); conn = DriverManager.getConnection("proxool." + db); if(conn!=null) System.out.println("数据连接测试成功!"); Statement Stmt=conn.createStatement(); ResultSet Rst=null; Rst=Stmt.executeQuery("select * from testTable"); while(Rst.next()) System.out.println(Rst.getString("name")); }catch(SQLException e) { System.out.println("error : "+e); }catch(ProxoolException e1){ System.out.println(e1); } finally{ try{ if (conn != null) conn.close(); }catch(SQLException e2){ System.out.println(e2); } } } } 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |