⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sweetboarddb.java

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA
字号:
package com.redmoon.forum.plugin.sweet;

import java.sql.*;

import cn.js.fan.base.ObjectDb;
import cn.js.fan.db.Conn;
import cn.js.fan.db.PrimaryKey;

public class SweetBoardDb extends ObjectDb {

    public SweetBoardDb() {
        init();
    }

    public SweetBoardDb(String boardCode) {
        this.boardCode = boardCode;
        init();
        load();
    }

    public boolean create(String boardCode, String sweetRule) {
        // logger.info("boardCode=" + boardCode);
        int rowcount = 0;
        Conn conn = null;
        try {
            conn = new Conn(connname);
            PreparedStatement ps = conn.prepareStatement(this.QUERY_CREATE);
            ps.setString(1, boardCode);
            ps.setString(2, sweetRule);
            rowcount = conn.executePreUpdate();
        } catch (SQLException e) {
            logger.error("create:" + e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount > 0 ? true : false;
    }

    public boolean del() {
        int rowcount = 0;
        Conn conn = null;
        try {
            conn = new Conn(connname);
            PreparedStatement ps = conn.prepareStatement(this.QUERY_DEL);
            ps.setString(1, boardCode);
            rowcount = conn.executePreUpdate();

            SweetBoardCache sc = new SweetBoardCache(this);
            sc.refreshDel(primaryKey);
        } catch (SQLException e) {
            logger.error(e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount > 0 ? true : false;
    }

    public SweetBoardDb getSweetBoardDb(String boardCode) {
        return (SweetBoardDb)getObjectDb(boardCode);
    }

    public ObjectDb getObjectDb(Object primaryKeyValue) {
        SweetBoardCache sc = new SweetBoardCache(this);
        primaryKey.setValue(primaryKeyValue);
        return sc.getObjectDb(primaryKey);
    }

    public int getObjectCount(String sql) {
        return 0;
    }

    public ObjectDb getObjectRaw(PrimaryKey pk) {
         return new SweetBoardDb(pk.getStrValue());
    }

    public void setQueryCreate() {
        this.QUERY_CREATE = "insert plugin_sweet_board (boardCode, sweetRule) values (?, ?)";
    }

    public void setQuerySave() {
        this.QUERY_SAVE = "update plugin_sweet_board set sweetRule=? where boardCode=?";
    }

    public void setQueryDel() {
        this.QUERY_DEL = "delete from plugin_sweet_board where boardCode=?";
    }

    public void setQueryLoad() {
        this.QUERY_LOAD =
            "select sweetRule from plugin_sweet_board where boardCode=?";
    }

    public void setQueryList() {
        this.QUERY_LIST = "select boardCode from plugin_sweet_board";
    }

    public boolean save() {
        int rowcount = 0;
        Conn conn = null;
        try {
            conn = new Conn(connname);
            PreparedStatement ps = conn.prepareStatement(QUERY_SAVE);
            ps.setString(1, sweetRule);
            ps.setString(2, boardCode);
            rowcount = conn.executePreUpdate();

            SweetBoardCache uc = new SweetBoardCache(this);
            primaryKey.setValue(boardCode);
            uc.refreshSave(primaryKey);
        } catch (SQLException e) {
            logger.error(e.getMessage());
        } finally {
            if (conn != null) {
                conn.close();
                conn = null;
            }
        }
        return rowcount>0? true:false;
    }

    public void load() {
        ResultSet rs = null;
        Conn conn = new Conn(connname);
        try {
            PreparedStatement ps = conn.prepareStatement(this.QUERY_LOAD);
            ps.setString(1, boardCode);
            rs = conn.executePreQuery();
            if (rs.next()) {
                sweetRule = rs.getString(1);
                primaryKey.setValue(boardCode);
                loaded = true;
            }
        } catch (SQLException e) {
            logger.error("load:" + e.getMessage());
        }
        finally {
            if (conn!=null) {
                conn.close();
                conn = null;
            }
        }
    }

    public Object[] getObjectBlock(String query, int startIndex) {
        return null;
    }

    public void setPrimaryKey() {
        this.primaryKey = new PrimaryKey("boardCode", primaryKey.TYPE_STRING);
    }

    public void setSweetRule(String sweetRule) {
        this.sweetRule = sweetRule;
    }

    public void setBoardCode(String boardCode) {
        this.boardCode = boardCode;
    }

    public String getSweetRule() {
        return sweetRule;
    }

    public String getBoardCode() {
        return boardCode;
    }

    private String sweetRule; // 本版关于情人路的规则

    private String boardCode;
    /**
     * isPluginBoard
     */
    public boolean isPluginBoard(String boardCode) {
        SweetBoardDb sb = (SweetBoardDb)getObjectDb(boardCode);
        if (sb.isLoaded())
            return true;
        else
            return false;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -