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

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

?? dbforumthread.java

?? 這是學習Java必須讀懂兩套源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * 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.sql.*;
import java.util.Date;
import java.util.Iterator;

import com.Yasna.forum.*;
import com.Yasna.util.Cacheable;
import com.Yasna.util.CacheSizes;

/**
 * Database implementation of the ForumThread interface.
 *
 * @see ForumThread
 */
public class DbForumThread implements ForumThread, Cacheable {

    /** DATABASE QUERIES **/
    private static final String MESSAGE_COUNT =
        "SELECT count(*) FROM yazdMessage WHERE threadID=?";
    private static final String ADD_MESSAGE =
        "INSERT INTO yazdMessageTree(parentID,childID) VALUES(?,?)";
    private static final String MOVE_MESSAGE =
        "UPDATE yazdMessageTree SET parentID=? WHERE childID=?";
    private static final String CHANGE_MESSAGE_THREAD =
        "UPDATE yazdMessage SET threadID=? WHERE messageID=?";
    private static final String UPDATE_THREAD_MODIFIED_DATE =
        "UPDATE yazdThread SET modifiedDate=? WHERE threadID=?";
    private static final String DELETE_MESSAGE1 =
        "DELETE FROM yazdMessageTree WHERE childID=?";
    private static final String DELETE_MESSAGE2 =
        "DELETE FROM yazdMessage WHERE messageID=?";
    private static final String DELETE_MESSAGE_PROPERTIES =
        "DELETE FROM yazdMessageProp WHERE messageID=?";
    private static final String LOAD_THREAD =
        "SELECT rootMessageID, creationDate, modifiedDate FROM yazdThread WHERE threadID=?";
    private static final String INSERT_THREAD =
        "INSERT INTO yazdThread(threadID,forumID, rootMessageID,creationDate," +
        "modifiedDate,approved) VALUES(?,?,?,?,?,?)";
    private static final String SAVE_THREAD =
        "UPDATE yazdThread SET rootMessageID=?, creationDate=?, " +
        "modifiedDate=? WHERE threadID=?";

    private int id = -1;
    //Temporary object reference for when inserting new record.
    private ForumMessage rootMessage;
    private int rootMessageID;
    private java.util.Date creationDate;
    private java.util.Date modifiedDate;
    private boolean approved;

    /**
     * Indicates if the object is ready to be saved or not. An object is not
     * ready to be saved if it has just been created and has not yet been added
     * to its container. For example, a message added to a thread, etc.
     */
    private boolean isReadyToSave = false;

    /**
     * The forum allows us access to the message filters.
     */
    private DbForum forum;

    /**
     * The factory provides services such as db connections and logging.
     */
    private DbForumFactory factory;

    /**
     * Creates a new DbForumThread. The supplied message object is used to
     * derive the name of the thread (subject of message), as well as the
     * creation date and modified date of thread.
     *
     * @param rootMessage the root message of the thread.
     */
    protected DbForumThread(ForumMessage rootMessage, boolean approved,
            DbForum forum, DbForumFactory factory) throws UnauthorizedException
    {
        this.id = DbSequenceManager.nextID("ForumThread");
        this.forum = forum;
        this.factory = factory;
        this.rootMessage = rootMessage;
        this.rootMessageID = rootMessage.getID();
        //Set the creation and modified dates to be the same as those of
        //root message.
        long rootMessageTime = rootMessage.getCreationDate().getTime();
        this.creationDate = new java.util.Date(rootMessageTime);
        this.modifiedDate = new java.util.Date(rootMessageTime);
        this.approved = approved;
    }

    /**
     * Loads a DbForumThread from the database based on its id.
     *
     * @param id in unique id of the ForumThread to load.
     * @param forum the Forum that the thread belongs to.
     * @param factory a ForumFactory to use for loading.
     */
    protected DbForumThread(int id, DbForum forum, DbForumFactory factory)
            throws ForumThreadNotFoundException
    {
        this.id = id;
        this.forum = forum;
        this.factory = factory;
        loadFromDb();
        isReadyToSave = true;
    }

    //FROM THE FORUMMESSAGE INTERFACE//

    public int getID() {
        return id;
    }

    public String getName() {
        return getRootMessage().getSubject();
    }

    public java.util.Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(java.util.Date creationDate)
            throws UnauthorizedException
    {
        this.creationDate = creationDate;
        //Only save to the db if the object is ready
        if (!isReadyToSave) {
            return;
        }
        saveToDb();
    }

    public java.util.Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(java.util.Date modifiedDate)
            throws UnauthorizedException
    {
        this.modifiedDate = modifiedDate;
        //Only save to the db if the object is ready
        if (!isReadyToSave) {
            return;
        }
        saveToDb();
    }

    public Forum getForum() {
        return forum;
    }

    public ForumMessage getMessage(int messageID)
            throws ForumMessageNotFoundException
    {
        ForumMessage message = factory.getMessage(messageID);

        //Apply filters to message.
        message = forum.applyFilters(message);
        return message;
    }

    public ForumMessage getRootMessage()  {
        try {
            return getMessage(rootMessageID);
        }
        catch (ForumMessageNotFoundException e) {
            System.err.println("Could not load root message with id " + rootMessageID);
            e.printStackTrace();
            return null;
        }
        /*DbForumMessage message = (DbForumMessage)factory.cacheManager.get(
                DbCacheManager.MESSAGE_CACHE,
                new Integer(rootMessageID)
        );
        if (message == null) {
            //Load and add to cache
            try {
                message = new DbForumMessage(rootMessageID, factory);
                factory.cacheManager.add(DbCacheManager.MESSAGE_CACHE, new Integer(rootMessageID), message);
            }
            catch (ForumMessageNotFoundException e) {
                System.err.println("Could not load root message with id " + rootMessageID);
                e.printStackTrace();
            }
        }
        return message;
        */
    }

    public int getMessageCount() {
        int messageCount = 0;
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            pstmt = con.prepareStatement(MESSAGE_COUNT);
            pstmt.setInt(1, id);
            ResultSet rs = pstmt.executeQuery();
            rs.next();
            messageCount = rs.getInt(1);
        }
        catch( SQLException sqle ) {
            System.err.println("DbForumThread:getMessageCount() failed: "+sqle);
        }
        finally {
            try {  pstmt.close(); }
            catch (Exception e) { e.printStackTrace(); }
            try {  con.close();   }
            catch (Exception e) { e.printStackTrace(); }
        }
        return messageCount;
    }

    public void addMessage(ForumMessage parentMessage, ForumMessage newMessage) {
        boolean abortTransaction = false;
        boolean supportsTransactions = false;
        //Add message to db
        Connection con = null;
        PreparedStatement pstmt = null;
        try {
            con = DbConnectionManager.getConnection();
            supportsTransactions = con.getMetaData().supportsTransactions();
            if (supportsTransactions) {
                con.setAutoCommit(false);
            }

            //Now, insert the message into the database.
            //Now, insert the message into the database.
            ((ForumMessageProxy)newMessage).insertIntoDb(con, this);

            pstmt = con.prepareStatement(ADD_MESSAGE);
            pstmt.setInt(1, parentMessage.getID());
            pstmt.setInt(2, newMessage.getID());
            pstmt.executeUpdate();
            pstmt.close();
        }
        catch( Exception e ) {
            e.printStackTrace();
            abortTransaction = true;
            return;
        }
        finally {
            try {
                if (supportsTransactions) {
                    if (abortTransaction == true) {
                        con.rollback();
                    }
                    else {
                        con.commit();
                    }
                }
            }
            catch (Exception e) { e.printStackTrace(); }
            try {
                if (supportsTransactions) {
                    con.setAutoCommit(true);
                }
                con.close();
            }
            catch (Exception e) { e.printStackTrace(); }
        }

        //Added new message, so update the modified date of this thread
        updateModifiedDate(newMessage.getModifiedDate());
        //Also, update the modified date of the forum
        DbForum dbForum = (DbForum)factory.cacheManager.get(
                DbCacheManager.FORUM_CACHE,
                new Integer(forum.getID())
            );
        if (dbForum != null) {
            dbForum.updateModifiedDate(modifiedDate);
        }
        else {
            forum.updateModifiedDate(modifiedDate);
        }
    }

    public void deleteMessage(ForumMessage message)
            throws UnauthorizedException
    {
        //Skip null messages or the case that we're already deleting the thread.
        if (message == null) {
            return;
        }
        //If the message does not belong to this thread, don't perform delete.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美成人综合网站| 亚洲欧美日韩系列| 国产老肥熟一区二区三区| 久久久九九九九| 国产永久精品大片wwwapp| 亚洲国产成人自拍| 亚洲国产美国国产综合一区二区| 亚洲午夜久久久| 国产成人av电影在线| 久久日韩粉嫩一区二区三区 | 久久综合色一综合色88| 卡一卡二国产精品| 精品免费一区二区三区| 久久成人精品无人区| 精品免费一区二区三区| 国内精品免费**视频| 2019国产精品| 欧美精选午夜久久久乱码6080| 亚洲尤物在线视频观看| 欧美日韩国产在线观看| 日韩成人伦理电影在线观看| 日韩一二三四区| 国产精品羞羞答答xxdd| 欧美一区二区视频在线观看| 免费成人av在线| 久久久久久久久99精品| 国产91丝袜在线播放0| 国产精品久线在线观看| 欧美日韩一二三| 另类专区欧美蜜桃臀第一页| 精品久久久久av影院| 成人黄色大片在线观看| 久久久高清一区二区三区| av成人老司机| 性久久久久久久久久久久| 日韩欧美国产系列| 精品综合免费视频观看| 国产精品乱人伦| 欧美日韩国产美| 国内精品久久久久影院色| 久久精品男人的天堂| 一本色道久久加勒比精品 | 久久久综合网站| 成人免费看视频| 午夜视频久久久久久| 久久亚洲二区三区| 色94色欧美sute亚洲线路二| 日韩高清一级片| 中文字幕乱码日本亚洲一区二区| 91欧美激情一区二区三区成人| 亚洲国产精品麻豆| 久久精品一区二区三区av| 色婷婷av一区二区三区大白胸| 图片区小说区国产精品视频| 国产欧美日韩视频一区二区| 91成人在线精品| 精品一区二区免费看| 亚洲影院免费观看| 国产午夜一区二区三区| 欧美乱妇一区二区三区不卡视频| 福利电影一区二区| 日本视频中文字幕一区二区三区| 欧美国产激情一区二区三区蜜月| 91精品国产一区二区| 色诱亚洲精品久久久久久| 国产一区二区三区在线观看免费 | 亚洲免费大片在线观看| 欧美一区日韩一区| 色综合天天综合网天天看片| 久久国产生活片100| 污片在线观看一区二区| 欧美丝袜自拍制服另类| 一区二区三区国产| 91成人免费网站| 日韩成人伦理电影在线观看| 日韩色在线观看| 久久一区二区三区四区| 日本一区中文字幕| 欧美另类z0zxhd电影| 欧美一卡二卡三卡四卡| 91亚洲资源网| 国产精品99久久久久久宅男| 亚洲精品欧美综合四区| 亚洲v日本v欧美v久久精品| 国产精品一线二线三线精华| 天天综合天天综合色| 日韩精品一区二区三区在线播放| 麻豆精品在线观看| 亚洲一区在线观看免费观看电影高清| 成人app软件下载大全免费| 亚洲三级电影网站| 国产精品网站在线播放| 欧美另类变人与禽xxxxx| 国产不卡视频一区二区三区| 久久草av在线| 久久精品国产网站| 日本精品裸体写真集在线观看| 国产精品一区2区| 欧洲视频一区二区| 在线不卡中文字幕| 久久这里只有精品视频网| 在线综合视频播放| 欧美手机在线视频| 久久久久国产精品麻豆ai换脸 | 国产精品久久一卡二卡| 精品久久久久久久久久久久久久久 | 久久精品无码一区二区三区| 粉嫩在线一区二区三区视频| 亚洲精品欧美综合四区| 国产精品成人一区二区艾草 | 色狠狠色噜噜噜综合网| 成人影视亚洲图片在线| 国产成人无遮挡在线视频| 国产在线视频一区二区三区| 久久99精品久久久久久国产越南| 91亚洲精华国产精华精华液| 欧美精品乱码久久久久久| 欧美xfplay| 中文字幕在线不卡| 一区二区日韩电影| 麻豆一区二区三| 国产福利精品一区二区| 亚洲图片激情小说| 九九九精品视频| 欧美刺激午夜性久久久久久久| 欧美mv日韩mv国产网站app| 色综合天天狠狠| 成人免费视频视频| 9191成人精品久久| 最新久久zyz资源站| 美国三级日本三级久久99| 色偷偷成人一区二区三区91| 日韩免费在线观看| 亚洲国产精品久久人人爱| 不卡一区二区中文字幕| 欧美成人综合网站| 无码av免费一区二区三区试看 | 国产麻豆成人传媒免费观看| 91黄色免费看| 欧美激情艳妇裸体舞| 免费av网站大全久久| 欧美日韩一区国产| 亚洲人成人一区二区在线观看 | 麻豆国产一区二区| 欧美中文字幕一区| ●精品国产综合乱码久久久久| 精品中文字幕一区二区| 91精品国产色综合久久| 亚洲国产成人91porn| 色偷偷久久一区二区三区| 中文字幕不卡在线| 懂色一区二区三区免费观看| 欧美不卡在线视频| 亚洲123区在线观看| 色综合天天综合网天天看片| 国产精品美女久久久久aⅴ国产馆| 国产自产高清不卡| 精品成a人在线观看| 国产真实乱偷精品视频免| 欧美一级在线视频| 美女诱惑一区二区| 日韩欧美亚洲国产另类| 天堂蜜桃一区二区三区| 欧美日韩一区二区欧美激情| 亚洲午夜一区二区| 美腿丝袜一区二区三区| 26uuuu精品一区二区| 黑人巨大精品欧美一区| 久久精品男人的天堂| 日本乱人伦一区| 国产高清久久久久| 国产精品的网站| 欧美久久久久久久久久| www.欧美.com| 奇米亚洲午夜久久精品| 中文一区在线播放| 欧美一级黄色录像| 中文字幕日本不卡| 国产精品99久久久久| 丁香天五香天堂综合| 欧美日韩免费在线视频| 亚洲国产毛片aaaaa无费看| 欧美区在线观看| 精品一二线国产| 国产精品卡一卡二卡三| 在线亚洲欧美专区二区| 日本一不卡视频| 久久免费视频色| 99精品视频一区| 亚洲图片一区二区| 日韩写真欧美这视频| 成人午夜伦理影院| 亚洲已满18点击进入久久| 日韩美女天天操| 9l国产精品久久久久麻豆| 五月天激情小说综合| 国产亚洲欧洲997久久综合| 91福利国产精品| 国产在线视频一区二区| 亚洲欧美日韩精品久久久久|