spring中使用proxool作数据源连接池的配置

先下载:
 
  http://surfnet.dl.sourceforge.net/sourceforge/proxool/proxool-0.9.0RC2.zip


  web.xml

-------------------------


  <servlet>
    <servlet-name>proxoolServletConfigurator</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>
  <servlet>
    <servlet-name>proxooladmin</servlet-name>
    <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>proxooladmin</servlet-name>
    <url-pattern>/proxooladmin</url-pattern>
  </servlet-mapping>


-------------------------

  proxool.xml

-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<proxool-config>
  <proxool>
    <alias>blogdb</alias>
    <driver-url>jdbc:oracle:thin:@127.0.0.1:1521:ORADB</driver-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <driver-properties>
      <property name="user" value="lizongbo"/>
      <property name="password" value="password"/>
    </driver-properties>
    <maximum-connection-count>10</maximum-connection-count>
    <house-keeping-test-sql>select 1 from dual</house-keeping-test-sql>
  </proxool>
</proxool-config>

spring里:
两种配置:
a:  <!-- 与上面的proxool以及web.xml里结合使用-->
    <bean id="mainDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName">
    <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
    </property>
    <property name="url">
    <value>proxool.blogdb</value>
    </property>
    </bean>

b:<!-- 单独的类似dbcp的使用-->
  <bean id="mainDataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy-method="close">
    <property name="driver">
      <value>oracle.jdbc.driver.OracleDriver</value>
    </property>
    <property name="driverUrl">
      <value>jdbc:oracle:thin:lizongbo/[email protected]:1521:ORADB</value>    
<!--用户名和密码写在一起才调用成功,不然会报 调用无效的参数 错误,下面设置用户名和密码的property好像是无效的,其它数据库也是这样
比如mysql的也要把用户名和密码写在url里:<property name="driverUrl" value="jdbc:mysql://localhost:3306/blogdb?user=lizongbo&amp;password=lizongbo" />
-->
    </property>
    <property name="user"> <!-- 必须在这里也设置,但是 proxool却不使用它,或许是个bug-->
      <value>lizongbo</value>
    </property>
    <property name="password"> <!-- 必须在这里也设置,但是 proxool却不使用它,或许是个bug-->
      <value>lizongbo</value>
    </property>
    <property name="alias">
      <value>lizongbo</value>
    </property>
    <property name="houseKeepingSleepTime">
      <value>90000</value>
    </property>
    <property name="prototypeCount">
      <value>5</value>
    </property>
    <property name="maximumConnectionCount">
      <value>100</value>
    </property>
    <property name="minimumConnectionCount">
      <value>10</value>
    </property>
    <property name="trace">
      <value>true</value>
    </property>
    <property name="verbose">
      <value>true</value>
    </property>
  </bean>

你可能感兴趣的:(spring,oracle,mysql,xml,jdbc)