zoukankan      html  css  js  c++  java
  • proxool配置 Mr

    不从性能上去比较此连接池的优点,单从其多数据配置的灵活性,和连接池监控的方便性就足可以进行选择。

    其配置方法:

    jar:

    proxool-0.9.1.jar

    proxool-cglib.jar

    相关的数据库驱动包 

    web.xml配置

        <!-- 配置proxool连接池 -->
        <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/classes/proxool.properties</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
       <!-- 连接池监控配置 -->
           <servlet>
            <servlet-name>dbAdmin</servlet-name>
            <servlet-class>
                org.logicalcobwebs.proxool.admin.servlet.AdminServlet
            </servlet-class>
        </servlet>
            <servlet-mapping>
            <servlet-name>dbAdmin</servlet-name>
            <url-pattern>/dbAdmin</url-pattern>
        </servlet-mapping>

    proxool.properties配置:

    #--------jdbc-----------------
    jdbc-0.proxool.alias=proxool
    jdbc-0.proxool.driver-class=oracle.jdbc.driver.OracleDriver
    jdbc-0.proxool.driver-url=jdbc:oracle:thin:@192.168.101.32:2012:arsystem
    jdbc-0.user=lneoms_v4
    jdbc-0.password=ar#admin#
    
    jdbc-0.proxool.maximum-connection-count=15
    jdbc-0.proxool.prototype-count=4
    
    jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
    jdbc-0.proxool.verbose=true
    jdbc-0.proxool.statistics=15s,1m,1d
    jdbc-0.proxool.statistics-log-level=DEBUG

    代码中动态获取连接池:

    package com.ultrapower.weekly.util;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import com.ultrapower.weekly.servlet.Constants;
    import com.ultrapower.weekly.bean.TableSpaceInfo;
      
    /**     
     * 持久化适配类    
     * @author zhangxuegang       
     * @version 1.0     
     * @created 2012-7-31 下午03:07:53    
     */
    
    public class DataAdapter {
          
        /**     
         * 执行查询
         * @param sqlStr     
         * @return 
         */
        public ResultSet executeQuery(String sqlStr) {
            Connection conn = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            try {
                Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
            StringUtil  strUtils = new StringUtil();
            String alias = strUtils.checkNullString(PropertiesUtils.getProperty("jdbc-0.proxool.alias"));
            try {
            conn = DriverManager.getConnection("proxool." + alias);
            ps = conn.prepareStatement(sqlStr);
            rs = ps.executeQuery();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return rs;
        }
          
    }

    监控地址:

    http://localhost:8080/WeeklyReport/dbAdmin
    

      

  • 相关阅读:
    1115:直方图
    1114:白细胞计数
    1114:白细胞计数
    忘记mysql密码后重置密码
    pycharm中无法导入pip安装的包
    win7升级win10
    WIN7 Windows update提示不支持硬件
    getcwd() 和 os.path.realpath () 的区别
    selenium启动chrome时,弹出设置页面:Windows Defender 防病毒要重置您的设置
    ui测试如何检测页面差异
  • 原文地址:https://www.cnblogs.com/rafx/p/proxool.html
Copyright © 2011-2022 走看看