配置proxool连接池

配置proxool连接池的步骤:

1、创建一个proxool.xml文件在web-inf下面:
内容为:
<?xml version="1.0" encoding="ISO-8859-1"?>
<something-else-entirely>
  <proxool>
  <alias>proxool</alias>
  <driver-url>jdbc:oracle:thin:@219.232.241.14:1521:test</driver-url>
  <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
  <driver-properties>
     <property name="user" value="test" />
     <property name="password" value="test" />
  </driver-properties>
  <house-keeping-sleep-time>90000</house-keeping-sleep-time>
  <maximum-new-connections>50</maximum-new-connections>
  <prototype-count>3</prototype-count>
  <proxool.simultaneous-build-throttle>200</proxool.simultaneous-build-throttle>
  <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
        <maximum-connection-count>200</maximum-connection-count>
        <minimum-connection-count>20</minimum-connection-count>
</proxool>
</something-else-entirely>

说明:
(1)<alias>proxool</alias>这句是为文件起的别名,在程序中访问就是proxool. proxool,红色的后缀名就是起的别名。
(2)<load-on-startup>1</load-on-startup>志servlet加载顺序。中的值越小加载越早

2、在web.xml初始化
<servlet>
  <servlet-name>ServletConfigurator</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>

3、在程序中使用
public Connection getCon() {
  logger.info("使用proxool连接池。。。");
  Connection conn = null;
  try {
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
conn = DriverManager.getConnection("proxool.proxool");
  } catch (Exception e) {
logger.error("", e);
  }
return conn;
}

你可能感兴趣的:(oracle,xml,Web,jdbc,servlet)