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

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

?? dbconnectionmanager.java

?? Java數據庫連接池的應用
?? JAVA
字號:
package com.hoperun.connectionPool;
/**
 * DBConnectionManager
 *@author zhou_chenxi
 */

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;

public class DBConnectionManager {
    //The only instance of the class DBConnectionManager.
	static private DBConnectionManager instance;
    //The number of clinents.
	static private int clients;
    //A container丆preserve the drivers of the datebase.
	private ArrayList drivers=new ArrayList();
    //Access the name of the target in the connectionpool and this target itself,
	//in the form of name/value.
	private HashMap pools = new HashMap();
	
	/**
	 * If the only instance has been created丆return it;
	 * else create it in the init() from tje privte function.
	 */
	static synchronized public DBConnectionManager getInstance(){
		if (instance == null) { 
			instance = new DBConnectionManager(); 
		} 
		return instance;
	}
		
    /**
     * Build the private function in order to prevent 
     * other targets from establishing this kind of instance. 
     * @call init()
     */
	private DBConnectionManager(){
		 init(); 
	}
	
    /**
     * Free a connection by the name of the connectionpool.
     * @param name
     * @param con
     */
	public void freeConnection(String name,Connection con){
		//Get the connectionpool by its name.
		DBConnectionPool poolTemp = (DBConnectionPool) pools.get(name); 
		if (poolTemp!= null) { 
			//Free the connection.
			poolTemp.freeConnection(con); 
			System.out.println("Free the connection乧乧");
			clients--;
            //For test,show the connections.
			System.out.println("The number of free connections :"+DBConnectionPool.freeConnections.size());
		} 
	}
    /**
     * get a connection from the connectionpool by the name
     * @call getConnection(time).Put an acquiescence value myself.
     * @param name
     */
	public Connection getConnection(String name){
    	Connection con=null;
    	//Get the connectionpool.
    	DBConnectionPool poolTemp = (DBConnectionPool) pools.get(name);
    	//Get the connection.Acquiescence the timeout is 10000.
    	if(poolTemp!=null){
    		con=poolTemp.getConnection(10000);
    	if (con!= null)
    		System.out.println("Get the connection乧乧");
    	}
    	clients++;
    	//For test.Show the number of the clients.
    	System.out.println("The clients' number is:"+clients);
    	return con; 
     } 
    	 
    /**
     * get a connection from the connectionpool by the name and time,
     * @call getConnection(time)
     * @param name
     * @param time
     */
	public Connection getConnection(String name,long time){
		Connection con=null;
        //Get the connectionpool.
    	DBConnectionPool poolTemp = (DBConnectionPool) pools.get(name);
    	//Get the connection.
    	if(poolTemp!=null){
    		con=poolTemp.getConnection(time);
    	if (con!= null)
    		System.out.println("Get the connection乧乧");
    	}
    	clients++;
    	//For test.Show the number of the clients.
    	System.out.println("The clients' number is:"+clients);
    	return con; 
	}
	
	/**
	 * release all of the resource
	 */
	public synchronized void release(){
		if (clients!= 0){ 
			return; 
		}
		//release the pools
		Iterator allPools = pools.keySet().iterator(); 
		while (allPools.hasNext()) { 
			DBConnectionPool pool = (DBConnectionPool) pools.get(allPools.next()); 
			if(pool!=null)
				pool.release();
			System.out.println("Release the connectionpool乧乧");
		} 
		pools.clear();
		/**release the drivers
		Iterator allDrivers = drivers.iterator();
		while (allDrivers.hasNext()) { 
			Driver driver = (Driver) allDrivers.next(); 
			try { 
				DriverManager.deregisterDriver(driver); 
				} 
			catch (SQLException e) { 
				e.printStackTrace();
			} 
		}
		System.out.println("Drivers released done.");*/
		System.out.println("All source released.");
	}
	
    /**
     * Create one or more ConnectionPools according to the infomation of property file.
     * @param props
     */
	private void createPools(Properties props){
		String url=props.getProperty("URL").trim();
		String user=props.getProperty("USER").trim();
  	    String name=props.getProperty("NAME").trim();
  	    String password=props.getProperty("PASSWORD").trim();
  	    String maxcon=props.getProperty("MAXCONN").trim();
  	    int maxConn=Integer.valueOf(maxcon).intValue();
  	    if (maxConn<=0){
  		  System.out.println("The connectins are full.");
  		  maxConn=1;
  	  }
  	  DBConnectionPool poolTemp = new DBConnectionPool(name, url,    
                user, password, maxConn);
  	  //Put the pool's info to the Hashmap.
  	  pools.put(name, poolTemp);
	}
	
	/**
	 * Initial the example of the ConnectionPool.
	 */
	private void init(){
		Properties propsTemp = new Properties();
		try {
            //set the filepath of the ORCALE.Properties.
			InputStream fileinputstream = new 
			FileInputStream("./config/ORCALE.Properties");
			//Load the properties file.
			propsTemp.load(fileinputstream);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		loadDrivers(propsTemp);
  	    createPools(propsTemp);
	}
	
    /**
     * Load the properties driver.
     * @param props
     */
	private void loadDrivers(Properties props){
		String driverClasses = props.getProperty("DRIVER").trim(); 
		try { 
			Driver driver = (Driver) 
			Class.forName(driverClasses).newInstance(); 
			DriverManager.registerDriver(driver); 
			drivers.add(driver); 
			} 
		catch (Exception e) { 
			e.printStackTrace();
			} 
		}
	}
	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产中文字幕精品| 秋霞电影一区二区| 久久精品国产久精国产爱| 风间由美性色一区二区三区| 91免费国产在线| 欧美不卡一区二区三区四区| 亚洲色图第一区| 麻豆成人免费电影| 欧美在线一二三四区| 国产欧美日本一区二区三区| 亚洲国产精品一区二区久久| 成人免费看视频| 久久众筹精品私拍模特| 性做久久久久久久久| 97久久久精品综合88久久| 日韩精品一区二区三区中文精品 | 欧美一级高清大全免费观看| 午夜日韩在线电影| 色综合色综合色综合色综合色综合| 日韩久久久久久| 日韩国产高清在线| 欧洲精品中文字幕| 成人欧美一区二区三区视频网页| 国内精品伊人久久久久av影院 | 久久中文娱乐网| 日韩精品一二三四| caoporn国产一区二区| 亚洲精品一区二区三区四区高清 | 国产精品18久久久久久久久| 日韩一区二区中文字幕| 秋霞影院一区二区| 日韩一区二区影院| 蜜桃在线一区二区三区| 欧美日韩三级在线| 视频一区视频二区中文| 欧美日本在线看| 婷婷久久综合九色综合伊人色| 欧美亚洲日本国产| 亚洲成人免费在线| 69久久夜色精品国产69蝌蚪网| 五月激情综合色| 欧美日韩黄色一区二区| 午夜a成v人精品| 欧美一区二区三区啪啪| 奇米777欧美一区二区| 日韩欧美一区二区不卡| 老司机精品视频导航| 精品国产123| 国产一区二区三区免费观看| 久久一留热品黄| 欧美刺激午夜性久久久久久久| 日本不卡免费在线视频| 欧美大片一区二区三区| 免费人成在线不卡| 欧美激情在线一区二区| a在线播放不卡| 亚洲第一主播视频| 欧美成人猛片aaaaaaa| 韩国精品一区二区| 亚洲天堂网中文字| 欧美美女黄视频| 国产一区二区三区日韩| 中文字幕一区二区三区不卡| 色综合久久九月婷婷色综合| 亚洲v精品v日韩v欧美v专区| 2021中文字幕一区亚洲| 91在线精品一区二区三区| 亚洲综合免费观看高清完整版在线| 91精品国产91久久久久久一区二区| 韩日av一区二区| 一区二区三区中文免费| 日韩欧美一区二区三区在线| 成人免费视频视频在线观看免费| 亚洲一区二区三区爽爽爽爽爽| 日韩丝袜情趣美女图片| 成人精品免费网站| 日本午夜精品视频在线观看 | 精品捆绑美女sm三区| 成人午夜激情视频| 日韩中文字幕区一区有砖一区| 中文av一区特黄| 欧美精品在线观看一区二区| 国产成人小视频| 偷偷要91色婷婷| 亚洲女与黑人做爰| 精品国产91洋老外米糕| 91成人国产精品| 不卡的电影网站| 激情五月激情综合网| 亚洲资源中文字幕| 国产精品久久久久四虎| 日韩免费观看高清完整版| 91国模大尺度私拍在线视频| 精品一区二区三区欧美| 亚洲地区一二三色| 亚洲美女淫视频| 国产精品女同一区二区三区| 欧美成人一级视频| 91精品黄色片免费大全| 91美女在线观看| av在线这里只有精品| 国产成人在线影院 | 久久久久久夜精品精品免费| 欧美日韩精品一区二区三区| 国产精品2024| 国产伦精品一区二区三区免费| 亚洲va欧美va天堂v国产综合| 亚洲天堂2014| 国产精品免费视频观看| 亚洲高清不卡在线| 一区二区三区自拍| 亚洲精品乱码久久久久| 亚洲国产精品高清| 久久久av毛片精品| 2020国产精品自拍| 久久精子c满五个校花| 日韩欧美一区二区免费| 欧美一区二区国产| 日韩一区二区三区在线| 欧美日本精品一区二区三区| 欧美少妇xxx| 69堂成人精品免费视频| 欧美一级高清片| 精品国产伦一区二区三区观看体验| 91精品中文字幕一区二区三区| 欧美视频三区在线播放| 欧美日韩国产精品成人| 777xxx欧美| 欧美大片在线观看| 久久―日本道色综合久久| 2023国产精品自拍| 国产精品久久久久久亚洲毛片| 欧美激情在线一区二区三区| 欧美国产欧美亚州国产日韩mv天天看完整 | 欧美性欧美巨大黑白大战| 欧洲精品中文字幕| 日韩一卡二卡三卡| 久久综合丝袜日本网| 久久影视一区二区| 亚洲情趣在线观看| 日日夜夜免费精品视频| 蜜桃视频免费观看一区| 国产精品一区二区三区网站| 国产一区二区三区| 成人精品亚洲人成在线| 欧美性生活久久| www一区二区| 亚洲最新视频在线观看| 日韩成人午夜电影| 成人手机电影网| 欧美日韩国产综合视频在线观看| 精品国产乱码久久久久久蜜臀| 国产欧美日韩不卡免费| 亚洲免费观看高清完整版在线| 日韩不卡一二三区| 粉嫩嫩av羞羞动漫久久久| 色视频成人在线观看免| 日韩午夜av电影| 中文字幕亚洲不卡| 毛片不卡一区二区| 99精品热视频| 欧美成va人片在线观看| 亚洲嫩草精品久久| 久久国产精品99久久人人澡| 成人avav在线| 日韩一区二区三区高清免费看看 | 成人精品免费看| 91精品婷婷国产综合久久竹菊| 国产精品网站导航| 日本不卡123| a级高清视频欧美日韩| 日韩欧美一区在线观看| 亚洲乱码国产乱码精品精98午夜 | 久久精品人人做人人综合| 亚洲精品成人悠悠色影视| 久久99国产精品麻豆| 色狠狠一区二区三区香蕉| 欧美一个色资源| 亚洲综合小说图片| 国产成人精品影视| 日韩欧美一区在线观看| 亚洲mv大片欧洲mv大片精品| 国产酒店精品激情| 亚洲精品在线电影| 亚洲一区av在线| av综合在线播放| 欧美激情一区二区三区全黄| 免费久久99精品国产| 欧美日韩精品二区第二页| 亚洲另类中文字| 一本色道亚洲精品aⅴ| 国产午夜一区二区三区| 男男gaygay亚洲| 91精品国产高清一区二区三区 | 99久久久精品| 欧美激情一区二区三区在线| 日本一区中文字幕 | 精品一区二区免费视频| 欧美一区二区三区日韩视频| 三级在线观看一区二区|