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

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

?? connectionpool.java

?? java pos,你可以直接編譯運行,
?? JAVA
字號:
/* * Copyright (c) 2000 jPOS.org.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *    "This product includes software developed by the jPOS project  *    (http://www.jpos.org/)". Alternately, this acknowledgment may  *    appear in the software itself, if and wherever such third-party  *    acknowledgments normally appear. * * 4. The names "jPOS" and "jPOS.org" must not be used to endorse  *    or promote products derived from this software without prior  *    written permission. For written permission, please contact  *    license@jpos.org. * * 5. Products derived from this software may not be called "jPOS", *    nor may "jPOS" appear in their name, without prior written *    permission of the jPOS project. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   * IN NO EVENT SHALL THE JPOS PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  * POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the jPOS Project.  For more * information please see <http://www.jpos.org/>. */package org.jpos.tpl;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.util.Vector;import org.jpos.core.Configurable;import org.jpos.core.Configuration;import org.jpos.core.ConfigurationException;import org.jpos.util.LogSource;import org.jpos.util.Logger;import org.jpos.util.NameRegistrar;/** A class for preallocating, recycling, and managing *  JDBC connections. *  <P> *  Taken from Core Servlets and JavaServer Pages *  from Prentice Hall and Sun Microsystems Press, *  http://www.coreservlets.com/. *  &copy; 2000 Marty Hall; may be freely used or adapted. *  @author Rajal Shah *  @version $Revision: 1.4 $ $Date: 2003/10/13 10:46:16 $ */public class ConnectionPool implements Runnable, LogSource, Configurable {    Configuration cfg;    Logger logger;    String realm;    private String driver, url, username, password;    private int maxConnections;    private boolean waitIfBusy;    private Vector availableConnections, busyConnections;    private boolean connectionPending = false;   /**    * no args constructor    */    public ConnectionPool () {        super();    }    public void setConfiguration (Configuration cfg)        throws ConfigurationException    {        this.cfg = cfg;        initEngine();    }    private void initEngine () throws ConfigurationException {        initJDBC();    }    private void initJDBC() throws ConfigurationException {        try {            Class.forName(cfg.get("jdbc.driver")).newInstance();        } catch (Exception e) {            throw new ConfigurationException (e);        }        driver = cfg.get("jdbc.driver");        url    = cfg.get("jdbc.url");        username = cfg.get("jdbc.user");        password = cfg.get("jdbc.password");        int initialConnections = cfg.getInt("initial-connections");        maxConnections = cfg.getInt("max-connections");        waitIfBusy = cfg.getBoolean("wait-if-busy");        if (initialConnections > maxConnections) {            initialConnections = maxConnections;        }        availableConnections = new Vector(initialConnections);        busyConnections = new Vector();        for(int i=0; i<initialConnections; i++) {            try {                availableConnections.addElement(makeNewConnection());            } catch(SQLException e) {                throw new ConfigurationException(e);            }        }    }   /**    * To invoke the Connection Pool object directly without jPOS.    */    public ConnectionPool(String driver, String url,                        String username, String password,                        int initialConnections,                        int maxConnections,                        boolean waitIfBusy)        throws SQLException    {        this.driver = driver;        this.url = url;        this.username = username;        this.password = password;        this.maxConnections = maxConnections;        this.waitIfBusy = waitIfBusy;        if (initialConnections > maxConnections) {            initialConnections = maxConnections;        }        availableConnections = new Vector(initialConnections);        busyConnections = new Vector();        for(int i=0; i<initialConnections; i++) {            availableConnections.addElement(makeNewConnection());        }    }    public synchronized Connection getConnection()        throws SQLException    {        if (!availableConnections.isEmpty()) {            Connection existingConnection =                (Connection)availableConnections.lastElement();            int lastIndex = availableConnections.size() - 1;            availableConnections.removeElementAt(lastIndex);            // If connection on available list is closed (e.g.,            // it timed out), then remove it from available list            // and repeat the process of obtaining a connection.            // Also wake up threads that were waiting for a            // connection because maxConnection limit was reached.            if (existingConnection.isClosed()) {                notifyAll(); // Freed up a spot for anybody waiting                return(getConnection());            } else {                busyConnections.addElement(existingConnection);                return(existingConnection);            }        } else {            // Three possible cases:            // 1) You haven't reached maxConnections limit. So            //    establish one in the background if there isn't            //    already one pending, then wait for            //    the next available connection (whether or not            //    it was the newly established one).            // 2) You reached maxConnections limit and waitIfBusy            //    flag is false. Throw SQLException in such a case.            // 3) You reached maxConnections limit and waitIfBusy            //    flag is true. Then do the same thing as in second            //    part of step 1: wait for next available connection.            if ((totalConnections() < maxConnections) && !connectionPending) {                makeBackgroundConnection();            } else if (!waitIfBusy) {                throw new SQLException("Connection limit reached");            }            // Wait for either a new connection to be established            // (if you called makeBackgroundConnection) or for            // an existing connection to be freed up.            try {                wait();            } catch (InterruptedException ie) {}            // Someone freed up a connection, so try again.            return(getConnection());        }    }    // You can't just make a new connection in the foreground    // when none are available, since this can take several    // seconds with a slow network connection. Instead,    // start a thread that establishes a new connection,    // then wait. You get woken up either when the new connection    // is established or if someone finishes with an existing    // connection.    private void makeBackgroundConnection() {        connectionPending = true;        try {            Thread connectThread = new Thread(this);            connectThread.start();        } catch(OutOfMemoryError oome) {        // Give up on new connection        }    }    public void run() {        try {            Connection connection = makeNewConnection();            synchronized(this) {                availableConnections.addElement(connection);                connectionPending = false;                notifyAll();            }        } catch(Exception e) { // SQLException or OutOfMemory            // Give up on new connection and wait for existing one            // to free up.        }    }    // This explicitly makes a new connection. Called in    // the foreground when initializing the ConnectionPool,    // and called in the background when running.    private Connection makeNewConnection()        throws SQLException {        try {            // Load database driver if not already loaded            Class.forName(driver);            // Establish network connection to database            Connection connection =                DriverManager.getConnection(url, username, password);            return(connection);        } catch(ClassNotFoundException cnfe) {            // Simplify try/catch blocks of people using this by            // throwing only one exception type.            throw new SQLException("Can't find class for driver: " +                                driver);        }    }    public synchronized void free(Connection connection) {        if(busyConnections.removeElement(connection)) {            availableConnections.addElement(connection);        }        // Wake up threads that are waiting for a connection        notifyAll();    }    public synchronized int totalConnections() {        return(availableConnections.size() + busyConnections.size());    }    public synchronized int getTotalConnections(){        return (availableConnections.size() + busyConnections.size());    }    /** Close all the connections. Use with caution:    *  be sure no connections are in use before    *  calling. Note that you are not <I>required</I> to    *  call this when done with a ConnectionPool, since    *  connections are guaranteed to be closed when    *  garbage collected. But this method gives more control    *  regarding when the connections are closed.    */    public synchronized void closeAllConnections() {        closeConnections(availableConnections);        availableConnections = new Vector();        closeConnections(busyConnections);        busyConnections = new Vector();    }    private void closeConnections(Vector connections) {        try {            for(int i=0; i<connections.size(); i++) {                Connection connection = (Connection)connections.elementAt(i);                if (!connection.isClosed()) {                    connection.close();                }            }        } catch(SQLException sqle) {            // Ignore errors; garbage collect anyhow        }    }    public synchronized String toString() {        String info =            "ConnectionPool(" + url + "," + username + ")" +            ", available=" + availableConnections.size() +            ", busy=" + busyConnections.size() +            ", max=" + maxConnections;        return(info);    }    public void setLogger (Logger logger, String realm) {        this.logger = logger;        this.realm  = realm;    }    public String getRealm () {        return realm;    }    public Logger getLogger() {        return logger;    }    /**     * @return ISOMUX instance with given name.     * @throws NameRegistrar.NotFoundException;     * @see NameRegistrar     */    public static ConnectionPool getConnectionPool (String name)        throws NameRegistrar.NotFoundException    {        return (ConnectionPool) NameRegistrar.get ("connection.pool."+name);    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性色欧美a在线播放| 久久精品国产免费| 99这里只有精品| 久久99蜜桃精品| 亚洲国产精品精华液网站| 国产精品污污网站在线观看| 日韩一区二区在线观看| 色哟哟一区二区| 激情综合亚洲精品| 亚洲国产精品一区二区尤物区| 国产欧美精品一区| 久久久www免费人成精品| 日韩一级高清毛片| 日韩久久久久久| 91精品免费观看| 欧美视频日韩视频在线观看| 99国产一区二区三精品乱码| 成人免费毛片片v| 成人激情电影免费在线观看| 国产a精品视频| 懂色av噜噜一区二区三区av | 久久精品国产成人一区二区三区 | 丝袜脚交一区二区| 亚洲丝袜自拍清纯另类| 亚洲欧美综合另类在线卡通| 国产精品免费视频一区| 日本一区二区三区四区在线视频 | 亚洲综合一区二区三区| 欧美激情一区二区| 国产精品久久久久永久免费观看| 精品国产三级a在线观看| 欧美α欧美αv大片| 日韩欧美二区三区| 久久色在线观看| 国产精品欧美一区喷水| 亚洲日本护士毛茸茸| 玉足女爽爽91| 一区二区三区日韩欧美精品| 亚洲高清视频在线| 日本一区中文字幕| 国产一区二区三区在线观看精品 | 制服丝袜日韩国产| 日韩丝袜美女视频| 国产欧美一区二区在线| 亚洲视频免费观看| 一区二区视频免费在线观看| 日本不卡视频在线观看| 国产一区二区三区黄视频| 成人免费三级在线| 欧美视频你懂的| 日韩片之四级片| 国产精品免费视频观看| 午夜精品一区二区三区三上悠亚| 玖玖九九国产精品| 欧美综合在线视频| 久久午夜老司机| 亚洲已满18点击进入久久| 人人狠狠综合久久亚洲| 9l国产精品久久久久麻豆| 日韩欧美精品在线| 亚洲美女屁股眼交| 韩国理伦片一区二区三区在线播放 | 欧美一级搡bbbb搡bbbb| 中文字幕 久热精品 视频在线 | 欧美最猛黑人xxxxx猛交| 欧美一区二区三级| 亚洲天天做日日做天天谢日日欢| 免费一区二区视频| 欧洲激情一区二区| 国产精品美女一区二区三区| 日韩国产精品久久| 精品视频123区在线观看| 国产亚洲1区2区3区| 日本特黄久久久高潮| 91久久香蕉国产日韩欧美9色| 久久婷婷一区二区三区| 久久av资源站| 欧美精选在线播放| 亚洲资源中文字幕| 成人夜色视频网站在线观看| 精品久久久久久亚洲综合网| 日韩av电影一区| 欧美精品 国产精品| 一区二区国产视频| 色狠狠色噜噜噜综合网| 国产欧美日韩亚州综合| 国产福利一区二区| 精品国产伦理网| 蜜臀久久99精品久久久画质超高清 | 中文字幕欧美一| 成人午夜看片网址| 国产精品色哟哟| 成人手机在线视频| 国产精品视频一二三区| 国产91精品一区二区| 国产清纯美女被跳蛋高潮一区二区久久w | 一区二区久久久久久| 久久成人羞羞网站| 国产日韩欧美精品在线| 久久精品国产久精国产爱| 精品粉嫩aⅴ一区二区三区四区| 亚洲国产你懂的| www.色综合.com| 欧美一区二区三区免费在线看| 1000部国产精品成人观看| 国产最新精品免费| 欧美大片在线观看一区二区| 婷婷六月综合网| 欧美日本视频在线| 亚洲一区在线视频观看| 在线观看日韩av先锋影音电影院| 亚洲激情校园春色| 中文字幕欧美一区| 丝袜亚洲另类丝袜在线| 精品欧美久久久| 色94色欧美sute亚洲线路二| 青青草97国产精品免费观看| 国产精品进线69影院| 日韩免费高清av| 91蝌蚪porny| 激情丁香综合五月| 一区二区激情视频| 国产精品你懂的| 欧美mv日韩mv| 69成人精品免费视频| 91丨porny丨最新| 极品少妇xxxx精品少妇| 午夜电影网一区| 亚洲欧美成人一区二区三区| 精品999在线播放| 欧美一级生活片| 精品视频1区2区3区| 色综合久久综合网欧美综合网| 极品少妇xxxx偷拍精品少妇| 亚洲va国产天堂va久久en| 成人欧美一区二区三区在线播放| 欧美成人福利视频| 在线成人高清不卡| 欧美色爱综合网| 色婷婷亚洲综合| 91麻豆精品视频| 一本在线高清不卡dvd| 国产91精品一区二区麻豆亚洲| 精品制服美女丁香| 乱一区二区av| 青青草97国产精品免费观看| 午夜精品久久久久久久99樱桃| 亚洲精品自拍动漫在线| 亚洲欧美日韩在线| 亚洲欧洲精品一区二区三区不卡| 久久人人97超碰com| 欧美不卡在线视频| 久久亚洲二区三区| 精品国产伦一区二区三区观看体验| 欧美一区二区三区四区在线观看| 欧美日韩综合一区| 欧美日韩另类国产亚洲欧美一级| 欧美色欧美亚洲另类二区| 在线观看av一区二区| 精品视频一区三区九区| 在线播放国产精品二区一二区四区 | 亚洲激情图片qvod| 夜夜揉揉日日人人青青一国产精品| 曰韩精品一区二区| 日韩精品视频网站| 麻豆国产精品官网| 国产精品资源在线观看| 成人av在线电影| 色呦呦国产精品| 欧美一区二区视频网站| 久久无码av三级| 亚洲欧美在线视频| 亚洲观看高清完整版在线观看| 亚洲二区在线视频| 激情丁香综合五月| av亚洲精华国产精华| 欧美综合在线视频| xfplay精品久久| 亚洲欧洲av另类| 日本欧美一区二区| 丁香激情综合五月| 欧美日韩亚洲丝袜制服| 久久这里只有精品视频网| 中文字幕一区二区三区在线不卡| 一区二区三区四区中文字幕| 日本亚洲电影天堂| 99国产一区二区三精品乱码| 欧美日韩卡一卡二| 日本一区二区三区四区在线视频| 亚洲激情自拍视频| 久草中文综合在线| 一本久久a久久精品亚洲| 日韩三级中文字幕| 亚洲视频精选在线| 免费高清视频精品| 99久久精品一区二区| 欧美一级国产精品| 亚洲一区二区三区四区五区中文 | 亚洲高清视频在线| 国产91在线观看|