亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dbconnectionmanager.java

?? cmpp2.0的網關 java源碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package com.hoten.db;

import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import com.hoten.util.Log;
/**
 * This class is a Singleton that provides access to one or many
 * connection pools defined in a Property file. A client gets
 * access to the single instance through the static getInstance()
 * method and can then check-out and check-in connections from a pool.
 * When the client shuts down it should call the release() method
 * to close all open connections and do other clean up.
 */
public class DBConnectionManager {
    static private DBConnectionManager instance; // The single instance
    static private int clients;
    private String logFile;
    private Vector drivers = new Vector();
    private Hashtable pools = new Hashtable();
  /**
 * Returns the single instance, creating one if it's the
 * first time this method is called.
 *
 * @return DBConnectionManager The single instance.
 */
    static synchronized public DBConnectionManager getInstance() {
        if (instance == null) {
            instance = new DBConnectionManager();
        }
        clients++;
        //System.out.println(clients);
        return instance;
    }
    public int getAccessNum(){
        return clients;
    }
    public String getLogFile(){
        return logFile;
    }
    public int getUsedConNum(String poolName){
        DBConnectionPool pool = (DBConnectionPool) pools.get(poolName);
        int size = 0;
        if (pool != null) {
            size = pool.getUsedConNum();
        }
        pool=null;
        return size;
    }
    public int getFreeConNum(String poolName){
        DBConnectionPool pool = (DBConnectionPool) pools.get(poolName);
        int size = 0;
        if (pool != null) {
            size = pool.getFreeConNum();
        }
        pool=null;
        return size;
    }
    public String[] getPoolName(){
        Enumeration names = pools.keys();
        String[] nameList = new String[pools.size()];
        int i=0;
        while(names.hasMoreElements()){
            nameList[i++] = (String)names.nextElement();
        }
        return nameList;
    }
/**
 * A private constructor since this is a Singleton
 */
    private DBConnectionManager() {
        init();
    }

/**
 * Returns a connection to the named pool.
 *
 * @param name The pool name as defined in the properties file
 * @param con The Connection
 */
    public void freeConnection(String name, Connection con) {
        DBConnectionPool pool = (DBConnectionPool) pools.get(name);
        if (pool != null) {
            pool.freeConnection(con);
        }
        pool=null;
    }

/**
 * Returns an open connection. If no one is available, and the max
 * number of connections has not been reached, a new connection is
 * created.
 *
 * @param name The pool name as defined in the properties file
 * @return Connection The connection or null
 */
    public java.sql.Connection getConnection(String name) {
       DBConnectionPool pool = (DBConnectionPool) pools.get(name);
        if (pool != null) {
            return pool.getConnection();
        }
        pool=null;
        return null;
    }

/**
 * Returns an open connection. If no one is available, and the max
 * number of connections has not been reached, a new connection is
 * created. If the max number has been reached, waits until one
 * is available or the specified time has elapsed.
 *
 * @param name The pool name as defined in the properties file
 * @param time The number of milliseconds to wait
 * @return Connection The connection or null
 */
    public java.sql.Connection getConnection(String name, long time) {

        DBConnectionPool pool = (DBConnectionPool) pools.get(name);
        if (pool != null) {
            return pool.getConnection(time);
        }
        pool=null;
        return null;
    }

/**
 * Closes all open connections and deregisters all drivers.
 */
    public synchronized void release() {
            // Wait until called by the last client
      if (--clients != 0) {
             return;
      }
      Enumeration allPools = pools.elements();
      while (allPools.hasMoreElements()) {
          DBConnectionPool pool = (DBConnectionPool) allPools.nextElement();
          pool.release();
      }
      Enumeration allDrivers = drivers.elements();
      while (allDrivers.hasMoreElements()) {
          Driver driver = (Driver) allDrivers.nextElement();
          try {
              DriverManager.deregisterDriver(driver);
              Log.printEvent("Deregistered JDBC driver " + driver.getClass().getName(),logFile);
          }
          catch (SQLException e) {
              Log.printEvent("Can't deregister JDBC driver: " + driver.getClass().getName()+" Exception:"+e.getMessage(),logFile);
          }
      }
  }

/**
 * Creates instances of DBConnectionPool based on the properties.
 * A DBConnectionPool can be defined with the following properties:
 * <PRE>
 * &lt;poolname&gt;.url The JDBC URL for the database
 * &lt;poolname&gt;.user  A database user (optional)
 * &lt;poolname&gt;.passwordA database user password (if user specified)
 * &lt;poolname&gt;.maxconn The maximal number of connections (optional)
 * </PRE>
 *
 * @param props The connection pool properties
 */
    private void createPools(Properties props) {
        Enumeration propNames = props.propertyNames();
        while (propNames.hasMoreElements()) {
            String name = (String) propNames.nextElement();
            if (name.endsWith(".url")) {
                String poolName = name.substring(0, name.lastIndexOf("."));
                String url = props.getProperty(poolName + ".url");
                if (url == null) {
                    Log.printEvent("No URL specified for " + poolName,logFile);
                    continue;
                }
                String user = props.getProperty(poolName + ".user");
                String password = props.getProperty(poolName + ".password");
                String maxconn = props.getProperty(poolName + ".maxconn", "3");
                String minconn = props.getProperty(poolName + ".minconn","1");
                String defconn = props.getProperty(poolName + ".defconn","2");
                int max,min,def;
                try {
                    max = Integer.valueOf(maxconn.trim()).intValue();
                    min = Integer.valueOf(minconn.trim()).intValue();
                    def = Integer.valueOf(defconn.trim()).intValue();
                }
                catch (Exception e) {
                    Log.printEvent("Invalid maxconn value " + maxconn + " for " + poolName,logFile);
                    Log.printEvent("Invalid minconn value " + minconn + " for " + poolName,logFile);
                    Log.printEvent("Invalid minconn value " + defconn + " for " + poolName,logFile);
                    max = 3;
                    min=1;
                    def=2;
                }
                DBConnectionPool pool = new DBConnectionPool(poolName, url.trim(), user, password, max,min,def);
                pools.put(poolName, pool);
                Log.printEvent("Initialized pool " + poolName,logFile);
            }
        }
  }

/**
 * Loads properties and initializes the instance with its values.
 */
    private void init() {
        FileInputStream is=null;
        try{
            if(System.getProperty("file.separator").equals("/"))
                is= new FileInputStream("./config/db.properties");
            else
                is= new FileInputStream(".\\config\\db.properties");
        }catch(FileNotFoundException e){
        System.out.println("File db.properties not found");
        }
        Properties dbProps = new Properties();
        try {
            dbProps.load(is);
        }
        catch (Exception e) {
            System.err.println("Can't read the properties file. " +
            "Make sure db.properties is in the CLASSPATH");
            return;
        }
        logFile = dbProps.getProperty("logFile", "DBConnectionManager.log");
        loadDrivers(dbProps);
        createPools(dbProps);
  }

/**
 * Loads and registers all JDBC drivers. This is done by the
 * DBConnectionManager, as opposed to the DBConnectionPool,
 * since many pools may share the same driver.
 *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国一区二区三区| 欧美精品在线观看一区二区| 91香蕉国产在线观看软件| 91.麻豆视频| 一区二区三区四区中文字幕| 激情丁香综合五月| 欧美人与禽zozo性伦| 国产精品国产自产拍高清av| 精品一区中文字幕| 欧美日韩国产高清一区二区 | 国产精品无人区| 日韩 欧美一区二区三区| 日本韩国精品在线| 国产欧美一区二区三区沐欲| 久久激情综合网| 欧美日韩国产综合视频在线观看| 国产精品美女久久久久高潮| 精品中文字幕一区二区小辣椒| 欧美日韩一区二区电影| 亚洲精品五月天| 99久久精品国产观看| 中文在线资源观看网站视频免费不卡| 免费国产亚洲视频| 欧美一区二区高清| 爽好多水快深点欧美视频| 欧美影院一区二区三区| 一区二区三区波多野结衣在线观看| 成人一级片网址| 国产精品污www在线观看| 国产传媒日韩欧美成人| 欧美精品一区二区三区视频| 激情综合五月婷婷| 久久综合九色综合欧美98| 精品无码三级在线观看视频| 日韩视频不卡中文| 国产高清精品久久久久| 精品99999| 丁香婷婷综合网| 国产精品久久久久9999吃药| 国产成人免费9x9x人网站视频| 国产午夜精品美女毛片视频| 国产成人亚洲综合a∨猫咪| 国产日韩精品一区二区浪潮av| 一区二区三区四区不卡在线 | 风间由美一区二区三区在线观看| 2021久久国产精品不只是精品| 国产麻豆视频精品| 中文一区二区完整视频在线观看| www.日韩精品| 亚洲图片欧美综合| 欧美一区二区久久久| 国产精品亚洲午夜一区二区三区| 亚洲国产精品成人久久综合一区| 99re在线精品| 日韩中文字幕亚洲一区二区va在线| 日韩欧美一区在线观看| 国产精品一区三区| 亚洲日本va午夜在线电影| 欧美日韩在线电影| 久久爱另类一区二区小说| 国产精品久久久久久久久果冻传媒| 色婷婷综合激情| 捆绑紧缚一区二区三区视频 | 亚洲高清三级视频| 亚洲精品一区二区三区蜜桃下载 | 精品亚洲成a人在线观看| 国产精品嫩草影院com| 欧美性做爰猛烈叫床潮| 美女免费视频一区二区| 最好看的中文字幕久久| 欧美疯狂做受xxxx富婆| 成人美女视频在线观看| 午夜日韩在线电影| 亚洲国产精品传媒在线观看| 欧美猛男男办公室激情| 国产成人一级电影| 日本中文字幕一区| 中文字幕一区二区日韩精品绯色| 91精品欧美综合在线观看最新 | 一区在线播放视频| 欧美绝品在线观看成人午夜影视| 国产成人免费在线观看| 亚洲成人黄色影院| 最新日韩在线视频| 精品动漫一区二区三区在线观看| 在线观看免费视频综合| 成人动漫一区二区| 久久国产精品99精品国产| 一区二区国产盗摄色噜噜| 久久久亚洲午夜电影| 在线观看91av| 91久久精品国产91性色tv| 国产成人亚洲精品青草天美 | 亚洲一区二区五区| 欧美国产日韩精品免费观看| 正在播放一区二区| 在线欧美日韩国产| 99v久久综合狠狠综合久久| 国产在线不卡一卡二卡三卡四卡| 日韩vs国产vs欧美| 亚洲电影一级黄| 一区二区三区免费在线观看| 亚洲丝袜另类动漫二区| 国产日韩欧美精品一区| 久久视频一区二区| 日韩欧美中文一区| 精品免费日韩av| 欧美www视频| 日韩精品中文字幕在线不卡尤物| 欧美精品18+| 欧美一区二区国产| 日韩久久久久久| 精品日韩一区二区三区| 日韩免费成人网| 欧美成人精品高清在线播放| 日韩小视频在线观看专区| 欧美一卡二卡三卡| 日韩欧美视频在线 | 欧美日韩国产综合久久| 欧美亚洲国产bt| 5566中文字幕一区二区电影| 欧美精品乱码久久久久久按摩 | 日韩电影在线一区| 日欧美一区二区| 久久国产精品一区二区| 床上的激情91.| 白白色 亚洲乱淫| 风间由美性色一区二区三区| eeuss鲁片一区二区三区在线观看| 成人免费观看男女羞羞视频| 99国产精品久久| 欧美日韩国产乱码电影| 日韩免费性生活视频播放| 久久久久久久av麻豆果冻| 国产精品大尺度| 亚洲高清在线视频| 精品一区二区三区免费毛片爱| 国产一区免费电影| 91美女片黄在线观看91美女| 欧美午夜电影网| 久久综合久久综合久久综合| 国产精品嫩草99a| 午夜视频久久久久久| 激情小说亚洲一区| 91香蕉国产在线观看软件| 在线不卡免费av| 国产嫩草影院久久久久| 亚洲午夜电影网| 国产美女av一区二区三区| 91小宝寻花一区二区三区| 6080亚洲精品一区二区| 国产日韩av一区| 偷窥国产亚洲免费视频| 国产精品一二三四区| 欧美最猛黑人xxxxx猛交| 精品国产在天天线2019| 一区二区欧美在线观看| 精品亚洲成av人在线观看| 91免费版pro下载短视频| 日韩欧美国产精品一区| 亚洲精品国产视频| 激情深爱一区二区| 欧美亚洲国产怡红院影院| 久久久久久电影| 日韩av中文字幕一区二区| 不卡一区在线观看| 欧美xingq一区二区| 亚洲一区中文日韩| 成人av综合一区| 久久在线免费观看| 青娱乐精品视频| 欧美在线播放高清精品| 中文字幕国产一区| 精品一区二区免费| 欧美精品xxxxbbbb| 亚洲黄色av一区| 成人v精品蜜桃久久一区| 欧美xxxx在线观看| 日韩成人一级片| 欧美三级电影精品| 亚洲精品乱码久久久久久| www.66久久| 国产精品视频一二| 国产高清成人在线| 欧美精品一区二区三区四区 | 国产91精品免费| 欧美成人vps| 美女网站色91| 欧美一区二区视频在线观看| 亚洲国产综合在线| 在线观看不卡一区| 亚洲精品网站在线观看| 91香蕉视频污| 国产精品国产a级| 成人激情综合网站| 国产欧美日韩精品一区| 国产黄人亚洲片| 欧美国产日韩一二三区| 成人永久看片免费视频天堂| 国产嫩草影院久久久久|