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

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

?? psqlpool.java

?? 利用廣度優先遍歷搜索一定范圍內的所有網頁,可用于建立搜索引擎和查找網絡錯誤.
?? JAVA
字號:
package db;


import java.sql.*;
import java.util.*;
import io.*;

public abstract class PsqlPool {
	public static Hashtable<Connection, Boolean> connections = new Hashtable<Connection, Boolean>();;
	private static int increment=2;		// the number of connections to be incremented at a time.
	private static int intialConnections=1;
	private static String dbURL, user, password;

	//public PsqlPool(String connStr, String username, String pwd ) {
	public static void init(String connStr, String username, String pwd ) {
		dbURL = connStr;
		user = username;
		password = pwd;

		MyPrintStream.out.println("[PsqlPool] User: " + user + ", Password: " + password + ", Connection string: " + dbURL);
		//DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());

		// load the postgresql driver
		try {
			// load the postgresql driver
			Class.forName("org.postgresql.Driver");	
		}
		catch (ClassNotFoundException e) {
			System.err.println("[PsqlPool] Can't load the postgresql driver.");
			System.exit(1);
		}

		try {
			if( connections.size() == 0 ) {
				MyPrintStream.out.println("[PsqlPool] Initializing PostgreSQL Connection Pool.");
				// Put pool of connection into hashtable
				// set value to false to show connection not in use
				for( int i = 0; i < intialConnections; i++ ) {
					MyPrintStream.out.println("[PsqlPool] Pool count: " + i);
					//Connection conn = DriverManager.getConnection(dbURL, user, password);
					connections.put(DriverManager.getConnection(dbURL, user, password), Boolean.FALSE);
				} // for i
			} // if
		} catch(SQLException e) {
			//System.err.println("[PsqlPool] Creation of Pool instance un-successful");
			e.printStackTrace( MyPrintStream.out );
		}
	}

	public static Connection getConnection() throws SQLException {
		Connection con = null;

		Enumeration conxxx = connections.keys();
		int y=0;
		while( conxxx.hasMoreElements() ) {
			y++;
			con = (Connection)conxxx.nextElement();
			
			if( _DEBUG_PSQLPOOL )
				MyPrintStream.out.println("[PsqlPool.getConnection] Pool #" + y + ", in-use: " + connections.get(con).toString());
		} // while

		Enumeration cons = connections.keys();
		synchronized( connections ) {
			y=0;
			while( cons.hasMoreElements() ) {
				y++;
				con = (Connection)cons.nextElement();

				Boolean b = (Boolean)connections.get(con);
				if( b == Boolean.FALSE ) {
					try{
						if( _DEBUG_PSQLPOOL )
							MyPrintStream.out.println("[PsqlPool.getConnection] Attempting to use connection pool #" + y);
						//Found an unused connection
						//test to determine if good connection
						// If the connection isn't operable, you'll get an SQLException if
						// you attempt to execute anything over it
						con.setAutoCommit(true);

						Statement stmt = con.createStatement();
						//MyPrintStream.out.println("[PsqlPool.getConnection] Statement stmt = " + stmt);

						ResultSet rs = stmt.executeQuery("select 1+3");

						// Do some arbitrary database work
						if( rs!=null ) {
							while (rs.next()) {;}
						}
						rs.close();
						stmt.close();
					} catch(SQLException e) {
						//MyPrintStream.out.println("[PsqlPool.getConnection] Use of Pool #" + y + " Failed! Replacing this Connection Object.");
						e.printStackTrace( MyPrintStream.out );

						//problem with connection - replace the connection
						//con = DriverManager.getConnection(dbURL, user, password);
					} //catch sqlexception

					// Update connection hash table to show connection in use
					connections.put(con, Boolean.TRUE);

					// return the connection
					return con;
				} //if con not in use?
			} //end of while loop
		} //end of synchronized block

		// if reach this point there were no free connection objects
		// need to create some more
		MyPrintStream.out.println("[PsqlPool.getConnection] No connection pool available. Increment the pool size by "+increment+" to "+(connections.size()+2)+".");
		for( int i=0; i<increment; i++ ) {
			connections.put(DriverManager.getConnection(dbURL, user, password), Boolean.FALSE);
		}
		// Recurse to get one of the new connection
		return getConnection();
	}

	public static void returnConnection(Connection returned){
		Connection con;
		Enumeration cons = connections.keys();
		while(cons.hasMoreElements()){
			con = (Connection)cons.nextElement();
			if( con == returned ) {
				connections.put(con, Boolean.FALSE);
				break;
			} // if
		} // while
		if( _DEBUG_PSQLPOOL )
			MyPrintStream.out.println("[PsqlPool.returnConnection] returned.");
	}
	public static void connClose(ResultSet rs, Statement stmt, Connection conn){
		try{			if (rs != null) rs.close();			if (stmt != null) stmt.close();			if (conn != null) returnConnection(conn);
		} catch (Exception e) {			e.printStackTrace( MyPrintStream.out );
		}
	}
	public static int size() {
		return connections.size();
	}	@SuppressWarnings("unused")
	private void stmtClose(ResultSet rs, Statement stmt){		try{			if( rs!=null ) rs.close();			if( stmt!=null ) stmt.close();		}		catch (Exception e){			System.out.print("Exception in pool.stmtClose()\r\n " + e);
			e.printStackTrace();
		}
	}
	public static void main (String args[]) {
		String dbHostName = "jdbc:postgresql://localhost:5432/crawler";
		String dbUsername = "postgres";
		String dbPassword = "postgres";

		//PsqlPool pool = new PsqlPool(dbHostName, dbUsername, dbPassword);
		PsqlPool.init(dbHostName, dbUsername, dbPassword);
		Connection conn = null;
		ResultSet rs = null;
		Statement stmt = null;

		String buf;

		try {
			for( int j=0; j<5; j++ ) {
				//pool = new PsqlPool(dbHostName, dbUsername, dbPassword);
				//conn = pool.getConnection();
				conn = PsqlPool.getConnection();
				stmt = conn.createStatement();

				rs = stmt.executeQuery(
						//"SELECT * FROM link WHERE target = 'http://www.apache.org/' ORDER BY source"
						"SELECT count(*) FROM link"
				);

				while (rs.next()) {
					buf = rs.getString(1);

					MyPrintStream.out.println("Tuple count: " + buf);
				} // End of while (rs.next())
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		//pool.connClose(rs, stmt, conn);
	} //End of main

	private static boolean _DEBUG_PSQLPOOL = false;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色久优优欧美色久优优| 日本va欧美va欧美va精品| 精品亚洲成a人在线观看| 欧美一区二区三区喷汁尤物| 亚洲成人在线免费| 91精品国产麻豆| 免费av网站大全久久| 欧美tickling网站挠脚心| 国产一区在线不卡| 国产精品丝袜91| 色综合色综合色综合| 亚洲成在线观看| 日韩一级欧美一级| 国产成人精品影视| 亚洲欧美综合另类在线卡通| 色94色欧美sute亚洲线路一久| 午夜精品久久久久久久99水蜜桃| 日韩视频永久免费| 国产高清一区日本| 亚洲影院免费观看| 精品成人免费观看| 91啪九色porn原创视频在线观看| 亚洲bt欧美bt精品| 国产日本亚洲高清| 欧美视频在线不卡| 精品一区二区影视| 亚洲女与黑人做爰| 欧美电视剧在线观看完整版| 成人美女视频在线观看| 亚洲一区二区成人在线观看| 精品国产亚洲在线| 色综合久久88色综合天天6| 久久激情综合网| 亚洲毛片av在线| 2020国产精品| 欧美日韩精品一区二区| 国产激情视频一区二区三区欧美 | 亚洲成av人综合在线观看| 欧美精品一区视频| 欧美日韩中文国产| 成人午夜看片网址| 另类小说欧美激情| 亚洲一区二区三区视频在线| 久久精品在线免费观看| 884aa四虎影成人精品一区| 成人亚洲一区二区一| 青娱乐精品视频| 亚洲一区二区三区中文字幕| 欧美激情一区二区在线| 日韩一区二区在线看片| 在线视频国内一区二区| 成人av在线网| 国产精品一区久久久久| 日韩不卡一区二区三区| 亚洲主播在线观看| 亚洲欧美日韩在线不卡| 中文字幕欧美激情一区| 欧美精品一区二区在线播放| 777亚洲妇女| 欧美影院一区二区| 色老汉av一区二区三区| av成人动漫在线观看| 国产成人午夜高潮毛片| 激情五月婷婷综合网| 蜜乳av一区二区| 欧美aⅴ一区二区三区视频| 亚洲一区视频在线| 亚洲午夜羞羞片| 亚洲一区二区三区四区五区黄 | 欧美日韩国产一区二区三区地区| 豆国产96在线|亚洲| 国内精品伊人久久久久影院对白| 日韩成人一级片| 日韩中文字幕1| 日韩电影免费在线| 美女诱惑一区二区| 精品一区二区三区免费毛片爱| 久久精品国产99| 九色|91porny| 国产.精品.日韩.另类.中文.在线.播放| 美女在线视频一区| 国产精一品亚洲二区在线视频| 国产一区二区三区蝌蚪| 国产在线精品不卡| 国产69精品久久久久777| av在线不卡观看免费观看| 一本色道亚洲精品aⅴ| 欧美日韩在线一区二区| 91精品国产综合久久久久久 | 久久久国产精品麻豆| 久久免费电影网| 国产精品久久久久久久久果冻传媒| 国产精品福利影院| 一区二区三区在线观看网站| 亚洲成av人影院在线观看网| 欧美aaaaaa午夜精品| 国产老妇另类xxxxx| 色综合久久天天| 欧美喷水一区二区| 精品999在线播放| 中文一区二区完整视频在线观看| ●精品国产综合乱码久久久久| 亚洲午夜精品在线| 另类调教123区 | 欧美在线视频全部完| 91麻豆精品国产91久久久更新时间| 日韩欧美一区在线| 欧美激情一区二区三区不卡| 久久国产视频网| 国产精品资源在线| 色哟哟亚洲精品| 欧美一级黄色片| 国产精品久久久久久久蜜臀| 午夜日韩在线观看| 国产精品888| 欧美日韩中文字幕一区二区| 2019国产精品| 亚洲国产精品一区二区尤物区| 毛片av一区二区| 91网站在线观看视频| 日韩一区二区三区四区五区六区 | 99麻豆久久久国产精品免费优播| 欧美午夜片在线观看| 欧美成va人片在线观看| 亚洲精品国产精品乱码不99| 久久精工是国产品牌吗| 在线观看网站黄不卡| 国产三级精品在线| 日韩精品午夜视频| 91色综合久久久久婷婷| 久久影音资源网| 五月婷婷综合激情| 91在线精品秘密一区二区| 欧美不卡视频一区| 亚洲电影一级片| 91老师片黄在线观看| 久久久久99精品国产片| 日本成人在线视频网站| 欧美综合天天夜夜久久| 国产精品女主播在线观看| 久久精品国产99国产精品| 欧美人动与zoxxxx乱| ...av二区三区久久精品| 国产精品一区二区三区网站| 欧美福利一区二区| 亚洲国产一区二区在线播放| gogo大胆日本视频一区| 久久精品日韩一区二区三区| 免费看精品久久片| 91麻豆精品国产91久久久久| 99热这里都是精品| 久久一夜天堂av一区二区三区 | 激情深爱一区二区| 欧美精品一二三| 一区二区三区中文字幕精品精品| 不卡高清视频专区| 国产精品高清亚洲| 波多野结衣亚洲| 国产精品久久久爽爽爽麻豆色哟哟 | 国产精品乱码一区二区三区软件 | 捆绑调教美女网站视频一区| 欧美在线观看一二区| 亚洲精品成人a在线观看| 91丨porny丨首页| 亚洲三级在线播放| 色综合色综合色综合色综合色综合| 中文字幕在线不卡国产视频| 波多野结衣91| 日韩美女视频19| 色999日韩国产欧美一区二区| 亚洲激情图片qvod| 欧美亚洲综合一区| 婷婷开心久久网| 欧美一二三四区在线| 精品影视av免费| 国产清纯美女被跳蛋高潮一区二区久久w | 麻豆精品新av中文字幕| 日韩小视频在线观看专区| 久久国产福利国产秒拍| 精品少妇一区二区三区免费观看| 久久91精品国产91久久小草| 精品一区在线看| 久久影院午夜论| 福利91精品一区二区三区| 日韩美女久久久| 欧美日韩免费不卡视频一区二区三区 | 不卡高清视频专区| 亚洲综合图片区| 欧美一区二区三区婷婷月色| 久久国产精品99精品国产| 国产偷v国产偷v亚洲高清| 9i看片成人免费高清| 艳妇臀荡乳欲伦亚洲一区| 4438亚洲最大| 成人午夜碰碰视频| 亚洲一级在线观看| 精品成人私密视频| 91在线播放网址| 日韩高清欧美激情| 日本一区二区三区久久久久久久久不|