本人微信公众号"aeolian"~

Proxool连接池

proxool.xml

可以配置多个数据源。

xml version="1.0" encoding="UTF-8"?>
<something-else-entirely>
    <proxool>
       <alias>assetalias>
       <driver-url>jdbc:mysql://127.0.0.1:3306/jsxy?useUnicode\=true&characterEncoding\=UTF-8driver-url>
       <driver-class>com.mysql.jdbc.Driverdriver-class>
       <driver-properties>
          <property name="user" value="root"/>
           <property name="password" value="root"/>
       driver-properties>
       <minimum-connection-count>2minimum-connection-count>
       <prototype-count>2prototype-count>
       <maximum-connection-count>50maximum-connection-count>
       <house-keeping-sleep-time>60000house-keeping-sleep-time>
       <simultaneous-build-throttle>10simultaneous-build-throttle>
       <test-before-use>truetest-before-use>
       <house-keeping-test-sql>select now()house-keeping-test-sql>
       <injectable-prepared-statement-interface>java.sql.PreparedStatementinjectable-prepared-statement-interface>
   proxool>
   <proxool>
      <alias>jpaassetalias>
      <driver-url>jdbc:mysql://127.0.0.1:3306/jsxy?useUnicode\=true&characterEncoding\=UTF-8driver-url>
      <driver-class>com.mysql.jdbc.Driverdriver-class>
      <driver-properties>
         <property name="user" value="root"/>
         <property name="password" value="root"/>
      driver-properties>
      <minimum-connection-count>2minimum-connection-count>
      <prototype-count>2prototype-count>
      <maximum-connection-count>50maximum-connection-count>
      <house-keeping-sleep-time>60000house-keeping-sleep-time>
      <simultaneous-build-throttle>10simultaneous-build-throttle>
      <test-before-use>truetest-before-use>
      <house-keeping-test-sql>select now()house-keeping-test-sql>
      <injectable-prepared-statement-interface>java.sql.PreparedStatementinjectable-prepared-statement-interface>
   proxool>
something-else-entirely>

web.xml

    
    <servlet>
        <servlet-name>proxoolServletConfiguratorservlet-name>
        <servlet-class>
            org.logicalcobwebs.proxool.configuration.ServletConfigurator
        servlet-class>
        <init-param>
            <param-name>xmlFileparam-name>
            <param-value>WEB-INF/classes/jdbcproxool.xmlparam-value>
        init-param>
        <load-on-startup>1load-on-startup>
    servlet>

    
    <servlet>
        <servlet-name>Adminservlet-name>
        <servlet-class>
            org.logicalcobwebs.proxool.admin.servlet.AdminServlet
        servlet-class>
    servlet>
    <servlet-mapping>
        <servlet-name>Adminservlet-name>
        <url-pattern>/proxoolAdminurl-pattern>
    servlet-mapping>

这里org.logicalcobwebs.proxool.configuration.ServletConfigurator加载一定要早于org.springframework.web.context.ContextLoaderListener。

Spring-Dao.xml

spring中使用proxool作为spring jdbc template的数据源。

    
    
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.logicalcobwebs.proxool.ProxoolDriver"/>
        <property name="url" value="proxool.asset"/>
    bean>
    
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    bean>
    
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource">property>
    bean>
    
    <tx:annotation-driven transaction-manager="txManager"/>

启动时报错

详情

 
点赞

Leave a Reply

Your email address will not be published. Required fields are marked *