• Proxool连接池


    proxool.xml

    可以配置多个数据源。

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

    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/classes/jdbcproxool.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <!--proxool监控-->
        <servlet>
            <servlet-name>Admin</servlet-name>
            <servlet-class>
                org.logicalcobwebs.proxool.admin.servlet.AdminServlet
            </servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Admin</servlet-name>
            <url-pattern>/proxoolAdmin</url-pattern>
        </servlet-mapping>

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

    Spring-Dao.xml

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

        <!--spring jdbc template-->
        <!--datasource-->
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="org.logicalcobwebs.proxool.ProxoolDriver"/>
            <property name="url" value="proxool.asset"/>
        </bean>
        <!--jdbcTemplate使用datasource-->
        <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"/>

    启动时报错

    详情

     
  • 相关阅读:
    JavaScript 操作 DOM 元素
    字节数
    如何判断校准曲线是否合格
    [WPF]MVVM模式下如何在后台cs中调用绑定命令
    逆对数antilog0.03376如何计算
    未能解析此远程名称:'nuget.org' 的解决方法
    【WPF】WPF ScorllView触摸滚动实现
    【VS2017】清除NuGet下载旧版本缓存
    【UWP】截图
    test
  • 原文地址:https://www.cnblogs.com/aeolian/p/12674172.html
Copyright © 2020-2023  润新知