proxool 简单应用

1.下载所必需jar包。包括log4j的jar包。
2.在web.xml中加入
<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/proxool.properties</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>
注:
<init-param>
    <param-name>propertyFile</param-name>
    <param-value>WEB-INF/proxool.properties</param-value>
  </init-param>
可以替换为
<init-param>
    <param-name>xmlFile</param-name>
    <param-value>WEB-INF/proxool.xml</param-value>
  </init-param>

web.xml 配置完成
3.配置文件 2选1,和web.xml 中的对应。proxool.xml 和proxool.properties的内容分别如下:
xml 代码:
<?xml version="1.0" encoding="ISO-8859-1"?>
<proxool>
    <alias>xml-test</alias>
    <driver-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hih</driver-url>
    <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
    <driver-properties>
      <property name="user" value="sa"/>
      <property name="password" value="sa"/>
    </driver-properties>
    <maximum-connection-count>10</maximum-connection-count>
    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
  </proxool>
properties代码:
jdbc-0.proxool.alias=property-test
jdbc-0.proxool.driver-url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=hih
jdbc-0.proxool.driver-class=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc-0.user=sa
jdbc-0.password=sa
jdbc-0.proxool.maximum-connection-count=10
jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
4.得到connection的java代码:
try{
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
Connection con = DriverManager.getConnection("proxool.xml-test");
// Connection con = DriverManager.getConnection("proxool.property-test");
return con;
}catch(Exception e){}

配置文件打包了。

你可能感兴趣的:(log4j,xml,Web,jdbc,Microsoft)