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

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

?? dbsequencemanager.java

?? 這是學習Java必須讀懂兩套源代碼
?? JAVA
字號:
/**
 * Copyright (C) 2001 Yasna.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * 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
 *        Yasna.com (http://www.yasna.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Yazd" and "Yasna.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact yazd@yasna.com.
 *
 * 5. Products derived from this software may not be called "Yazd",
 *    nor may "Yazd" appear in their name, without prior written
 *    permission of Yasna.com.
 *
 * 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 YASNA.COM 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 Yasna.com. For more information
 * on Yasna.com, please see <http://www.yasna.com>.
 */

/**
 * Copyright (C) 2000 CoolServlets.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * 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
 *        CoolServlets.com (http://www.coolservlets.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jive" and "CoolServlets.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact webmaster@coolservlets.com.
 *
 * 5. Products derived from this software may not be called "Jive",
 *    nor may "Jive" appear in their name, without prior written
 *    permission of CoolServlets.com.
 *
 * 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 COOLSERVLETS.COM 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 CoolServlets.com. For more information
 * on CoolServlets.com, please see <http://www.coolservlets.com>.
 */

package com.Yasna.forum.database;

import java.util.HashMap;
import java.sql.*;

/**
 * Manages sequences of unique ID's that get stored in the database. Database
 * support for sequences varies widely; some don't support them at all. So,
 * we handle unique ID generation with synchronized counters.<p>
 *
 * Selecting the initial ID for each sequence is trivial: we simply query the
 * database to get the last highest unique ID, and then add 1 to that.<p>
 *
 * This method only works if a single instance of Jive is pointed at a database.
 * Otherwise, the unique ID's will stop being unique. :) A refined class that
 * deals with this is coming soon.
 */
public class DbSequenceManager {

    private static final String NEXT_FORUM_ID = "SELECT max(forumID) FROM yazdForum";
    private static final String NEXT_THREAD_ID = "SELECT max(threadID) FROM yazdThread";
    private static final String NEXT_MESSAGE_ID = "SELECT max(messageID) FROM yazdMessage";
    private static final String NEXT_GROUP_ID = "SELECT max(groupID) FROM yazdGroup";
    private static final String NEXT_USER_ID = "SELECT max(userID) FROM yazdUser";

    /**
     * Singleton type access to the class.
     */
    private static DbSequenceManager sequenceManager = null;

    /**
     * Lock so that we can synchronize during initialization.
     */
    private static Object initLock = new Object();

    /**
     * Returns the next ID of the specified type.
     *
     * @param type the type of unique ID.
     * @return the next unique ID of the specified type.
     */
    public static int nextID(String type) {
        if (sequenceManager == null) {
            synchronized(initLock) {
                if (sequenceManager == null) {
                    sequenceManager = new DbSequenceManager();
                }
            }
        }
        return sequenceManager.nextUniqueID(type);
    }

    private HashMap uniqueIDCounters;

    /**
     * Creates a new DbSequenceManager and initializes all of the counters.
     */
    public DbSequenceManager() {
        uniqueIDCounters = new HashMap();
        //Forum counter.
        uniqueIDCounters.put("Forum", new Counter(getNextDbID(NEXT_FORUM_ID)));
        //ForumThread counter.
        uniqueIDCounters.put("ForumThread", new Counter(getNextDbID(NEXT_THREAD_ID)));
        //ForumMessage counter.
        uniqueIDCounters.put("ForumMessage", new Counter(getNextDbID(NEXT_MESSAGE_ID)));
        //Group counter.
        uniqueIDCounters.put("Group", new Counter(getNextDbID(NEXT_GROUP_ID)));
        //User counter.
        uniqueIDCounters.put("User", new Counter(getNextDbID(NEXT_USER_ID)));
    }

    /**
     * Provides the next available unique ID for a particular object type.
     * Essentially this provides for the functionality of an auto-increment
     * database field. Valid counter names are Forum, ForumThread, ForumMessage,
     * Group, and User.
     * <p>
     * Those that are integrating Jive into existing tables should be sure
     * that the table names match up so that the correct starting unique
     * id can be determined.
     */
    public int nextUniqueID(String counterName) {
        Counter counter = (Counter)uniqueIDCounters.get(counterName);
        return counter.next();
    }

    /**
     * Do a lookup to see what the next available unique ID is for a
     * particular table. Jive uses the convention of always making the name of
     * the column that holds the unique id be called id, so this works.
     */
    private int getNextDbID(String query) {
        int currentID = 0;
        Connection con = null;
        PreparedStatement pstmt = null;

        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(query);
            ResultSet rs = pstmt.executeQuery();
            rs.next();
            currentID = rs.getInt(1);
        }
        catch( Exception sqle ) {
            System.err.println("Error in DbSequenceManager:getNextDbID()-" + sqle);
            sqle.printStackTrace();
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        //If the table is empty, start with id 0
        if (currentID < 0) {
            currentID = 0;
        }
        return currentID;
    }

    /**
     * Internal class to keep track of the current count of a unique id.
     */
    private final class Counter {

        private int count;

        public Counter(int currentCount) {
            count = currentCount;
        }

        public final synchronized int next() {
            return (++count);
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美中文字幕亚洲一区二区va在线 | 精品视频1区2区| 日韩码欧中文字| 91麻豆精东视频| 亚洲激情欧美激情| 欧美日韩国产高清一区二区| 亚洲福利视频导航| 日韩区在线观看| 国产精品一级片在线观看| 国产精品系列在线| 欧洲亚洲精品在线| 免费人成精品欧美精品| 久久久久九九视频| 91在线视频观看| 日av在线不卡| 国产精品美女久久久久高潮| 欧洲一区在线电影| 精东粉嫩av免费一区二区三区| 国产欧美一区二区精品性| 91免费国产在线| 奇米一区二区三区| 国产精品乱人伦中文| 欧美日韩国产高清一区二区三区| 激情综合色综合久久综合| 国产精品久久看| 日韩午夜在线播放| 972aa.com艺术欧美| 日韩vs国产vs欧美| ...xxx性欧美| 欧美成人a在线| 色噜噜久久综合| 国产一区高清在线| 亚洲一二三四区| 国产欧美精品一区二区色综合朱莉| 欧美在线综合视频| 国产成人亚洲精品青草天美| 亚洲国产一区二区三区青草影视| 国产校园另类小说区| 欧美精品丝袜久久久中文字幕| 东方欧美亚洲色图在线| 日韩电影一区二区三区四区| 亚洲特级片在线| 久久久久久麻豆| 欧美欧美午夜aⅴ在线观看| 成人aa视频在线观看| 久久99精品久久久| 亚洲成人综合视频| 亚洲天天做日日做天天谢日日欢| 欧美xxxx老人做受| 欧美久久久久久蜜桃| 99久久综合99久久综合网站| 韩国成人在线视频| 蜜臀久久99精品久久久久久9| 亚洲视频免费在线| 国产目拍亚洲精品99久久精品| 日韩午夜精品视频| 欧美色综合网站| 91在线观看高清| 风间由美性色一区二区三区| 韩国成人在线视频| 韩国一区二区在线观看| 麻豆freexxxx性91精品| 香蕉成人啪国产精品视频综合网| 亚洲欧美电影院| 亚洲日本va午夜在线影院| 国产视频一区在线播放| 国产午夜精品一区二区| 久久精品视频一区二区| 精品va天堂亚洲国产| 欧美tickle裸体挠脚心vk| 日韩视频一区在线观看| 欧美一区二区三区日韩视频| 欧美伦理影视网| 9191久久久久久久久久久| 欧美少妇一区二区| 欧美精品1区2区| 欧美一区欧美二区| 日韩一级免费一区| 精品入口麻豆88视频| 日韩一区二区高清| 久久亚洲综合色| 久久蜜桃av一区二区天堂 | 91精品1区2区| 欧美性色黄大片| 欧美日韩国产在线观看| 欧美日本一区二区| 日韩视频123| 久久久精品国产免大香伊| 国产精品美女久久久久久久 | 国产尤物一区二区在线| 国产成人免费视| 99精品偷自拍| 欧美精品久久99| 精品国产在天天线2019| 国产农村妇女毛片精品久久麻豆| 欧美国产一区二区| 亚洲一区在线电影| 美国毛片一区二区| 国产夫妻精品视频| 97精品国产97久久久久久久久久久久| 色综合av在线| 日韩精品中午字幕| 国产精品美女久久久久久| 一区二区欧美精品| 国产自产2019最新不卡| 91偷拍与自偷拍精品| 91精品国产品国语在线不卡| 国产日韩v精品一区二区| 亚洲欧美日韩一区| 蜜桃视频一区二区三区在线观看| 国产精品白丝jk白祙喷水网站 | 91视频.com| 91精品国产综合久久久久久| 国产亚洲精品久| 亚洲成人综合视频| 99久久精品99国产精品| 欧美一区二区美女| 成人免费在线视频| 久久99国产精品久久99| 91网站最新地址| 亚洲精品一区二区三区影院| 亚洲自拍偷拍av| 国产999精品久久久久久| 欧美三级电影网| 日本一区二区三区久久久久久久久不 | 亚洲视频免费观看| 精品一区二区精品| 欧美三级电影在线看| 中文字幕精品一区| 久久国产人妖系列| 在线视频亚洲一区| 中文字幕巨乱亚洲| 国产中文一区二区三区| 欧美日韩亚洲综合| 国产精品对白交换视频 | 日韩毛片一二三区| 国产精品一区三区| 日韩欧美在线影院| 亚洲一二三四在线观看| 99精品视频在线播放观看| 久久久久88色偷偷免费| 日本aⅴ免费视频一区二区三区| 97精品久久久午夜一区二区三区| 国产视频一区二区三区在线观看| 日本aⅴ亚洲精品中文乱码| 欧美三级视频在线| 亚洲欧美国产77777| av电影在线观看一区| 精品成a人在线观看| 美女一区二区视频| 6080yy午夜一二三区久久| 亚洲免费av观看| eeuss鲁一区二区三区| 国产婷婷色一区二区三区| 国产中文一区二区三区| 久久午夜色播影院免费高清| 久久99国产精品免费网站| 精品日韩一区二区三区免费视频| 日韩专区一卡二卡| 在线播放中文字幕一区| 午夜精品久久久久久久99樱桃 | 日本视频在线一区| 欧美日本免费一区二区三区| 亚洲影视在线播放| 精品婷婷伊人一区三区三| 亚洲不卡av一区二区三区| 欧美在线观看视频在线| 亚洲午夜免费电影| 欧美日韩美女一区二区| 日韩 欧美一区二区三区| 91麻豆精品国产综合久久久久久| 午夜精品一区二区三区电影天堂 | 色88888久久久久久影院野外| 自拍偷拍亚洲欧美日韩| 91女人视频在线观看| 亚洲欧美激情在线| 在线日韩av片| 日日摸夜夜添夜夜添国产精品 | 在线国产亚洲欧美| 亚洲第一激情av| 欧美一级高清大全免费观看| 久久精品噜噜噜成人av农村| 欧美精品一区二| 国产尤物一区二区| 日韩理论电影院| 欧美日韩中文精品| 久久99国产精品麻豆| 国产欧美一区二区精品性色| 91免费国产在线| 日韩黄色免费网站| 久久久久高清精品| 99久久99久久精品国产片果冻| 亚洲精品欧美激情| 91精品国产综合久久久蜜臀粉嫩| 国产在线不卡一卡二卡三卡四卡| 亚洲欧美一区二区在线观看| 欧美日韩午夜精品| 国产不卡视频在线播放| 亚洲精品成a人| 日韩精品一区二区三区中文不卡|