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

📄 homedb.java

📁 cwbbs 云网论坛源码
💻 JAVA
字号:
package com.redmoon.forum.miniplugin.home;import java.sql.*;import java.util.Vector;import cn.js.fan.base.ObjectDb;import cn.js.fan.db.Conn;import cn.js.fan.db.PrimaryKey;import cn.js.fan.util.*;import com.redmoon.forum.*;import com.redmoon.forum.plugin.auction.AuctionShopDb;public class HomeDb extends ObjectDb {    final int id = 0;    private String hot;    public HomeDb() {        init();        load();    }        public boolean del() throws ErrMsgException, ResKeyException {        return false;    }        public ObjectDb getObjectRaw(PrimaryKey pk) {        return new HomeDb();    }        public void load() {        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        ResultSet rs = null;        try {            pstmt = conn.prepareStatement(this.QUERY_LOAD);            rs = conn.executePreQuery();            if (rs.next()) {                hot = rs.getString(1);                recommandBoard = rs.getString(2);                recommandMsg = rs.getString(3);                primaryKey.setValue(new Integer(id));            }        } catch (SQLException e) {            logger.error("load:" + e.getMessage());        } finally {            if (rs!=null) {                try {                    rs.close();                }                catch (Exception e) {}                rs = null;            }            if (pstmt!=null) {                try {                    pstmt.close();                }                catch (Exception e) {}                pstmt = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }    }        public boolean save() {                Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {            pstmt = conn.prepareStatement(this.QUERY_SAVE);            pstmt.setString(1, hot);            pstmt.setString(2, recommandBoard);            pstmt.setString(3, recommandMsg);            if (conn.executePreUpdate() == 1) {                HomeCache hc = new HomeCache(this);                primaryKey.setValue(new Integer(id));                hc.refreshSave(primaryKey);            } else                return false;        } catch (SQLException e) {            logger.error("save:" + e.getMessage());        } finally {            if (pstmt!=null) {                try {                    pstmt.close();                }                catch (Exception e) {}                pstmt = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public void initDB() {        this.tableName = "miniplugin_home";        primaryKey = new PrimaryKey("id", PrimaryKey.TYPE_INT);        objectCache = new HomeCache(this);                                        this.QUERY_LOAD =                "SELECT hot,recommandBoard,recommandMsg FROM " + tableName + " WHERE id=0";        this.QUERY_SAVE =                "UPDATE " + tableName +                " SET hot=?,recommandBoard=?,recommandMsg=? WHERE id=0";        isInitFromConfigDB = false;    }    public void setHot(String hot) {        this.hot = hot;    }    public void setRecommandBoard(String recommandBoard) {        this.recommandBoard = recommandBoard;    }    public void setRecommandMsg(String recommandMsg) {        this.recommandMsg = recommandMsg;    }    public String getHot() {        return hot;    }    public String getRecommandBoard() {        return recommandBoard;    }    public String getRecommandMsg() {        return recommandMsg;    }    public int[] getHotIds() {        HomeCache hc = new HomeCache(this);        return hc.getHotIds();    }    public String[] getRecommandBoards() {        HomeCache hc = new HomeCache(this);        return hc.getRecommandBoards();    }    public int[] getRecommandMsgs() {        HomeCache hc = new HomeCache(this);        return hc.getRecommandMsgs();    }    public HomeDb getHomeDb() {        return (HomeDb) getObjectDb(new Integer(id));    }    public MsgDb getMsgDbTopOne(String boardCode) {        MsgDb md = new MsgDb();                                                        String sql = "select id from sq_thread where boardcode="+StrUtil.sqlstr(boardCode)+" and msg_level<=" + MsgDb.LEVEL_TOP_BOARD + " ORDER BY redate desc";        ThreadBlockIterator irmsg = md.getThreads(sql, boardCode, 0, 1);        if (irmsg.hasNext()) {            md = (MsgDb) irmsg.next();        }        return md;    }    public Vector getBoardsByTodayPost(int count) {        Vector v = new Vector();        String sql = "select code from sq_board order by today_count desc";        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        ResultSet rs = null;        try {            pstmt = conn.prepareStatement(sql);            conn.setMaxRows(count);            rs = conn.executePreQuery();            conn.setFetchSize(count);            Directory dir = new Directory();            while (rs.next()) {                Leaf lf = dir.getLeaf(rs.getString(1));                if (lf!=null)                    v.addElement(lf);            }        } catch (SQLException e) {            logger.error("getBoardsByTodayPost:" + e.getMessage());        } finally {            if (rs!=null) {                try {                    rs.close();                }                catch (Exception e) {}                rs = null;            }            if (pstmt!=null) {                try {                    pstmt.close();                }                catch (Exception e) {}                pstmt = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }        return v;    }    public Vector getNewShop(int count) {        AuctionShopDb as = new AuctionShopDb();        String sql = "select userName from " + as.getTableName() + " order by openDate desc";        return as.list(sql, 0, count);    }    private String recommandBoard;    private String recommandMsg;}

⌨️ 快捷键说明

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