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

📄 infodb.java

📁 cwbbs 云网论坛源码
💻 JAVA
字号:
package com.redmoon.forum.plugin.info;import java.sql.*;import java.util.*;import cn.js.fan.base.ObjectDb;import cn.js.fan.db.Conn;import cn.js.fan.db.PrimaryKey;import cn.js.fan.util.*;import cn.js.fan.web.SkinUtil;public class InfoDb extends ObjectDb {    public InfoDb() {        super();    }    public InfoDb(long id) {        this.id = id;        init();        load();    }    public boolean del() throws ErrMsgException {        int rowcount = 0;        Conn conn = null;        try {            conn = new Conn(connname);            PreparedStatement ps = conn.prepareStatement(this.QUERY_DEL);            ps.setLong(1, id);            rowcount = conn.executePreUpdate();        } catch (SQLException e) {            logger.error("del:" + e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        if (rowcount > 0) {            InfoCache cc = new InfoCache(this);            primaryKey.setValue(new Long(id));            cc.refreshDel(primaryKey);                                }        return rowcount>0? true:false;    }    public ObjectDb getObjectRaw(PrimaryKey pk) {        return new InfoDb(pk.getLongValue());    }    public boolean create() throws ErrMsgException, ResKeyException {        int rowcount = 0;        Conn conn = null;        try {            conn = new Conn(connname);            PreparedStatement ps = conn.prepareStatement(this.QUERY_CREATE);            ps.setLong(1, id);            ps.setString(2, typeCode);            ps.setString(3, userName);            ps.setString(4, "" + System.currentTimeMillis());            rowcount = conn.executePreUpdate();        } catch (SQLException e) {            logger.error("create:" + e.getMessage());            throw new ResKeyException(new SkinUtil(), SkinUtil.ERR_DB);        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        InfoCache uc = new InfoCache(this);        uc.refreshCreate();        return rowcount>0? true:false;    }    public boolean save() {        int rowcount = 0;        Conn conn = null;        try {            conn = new Conn(connname);            PreparedStatement ps = conn.prepareStatement(this.QUERY_SAVE);            ps.setString(1, typeCode);            ps.setLong(2, id);            rowcount = conn.executePreUpdate();                    } catch (SQLException e) {            logger.error("save:" + e.getMessage());        } finally {            InfoCache uc = new InfoCache(this);            primaryKey.setValue(new Long(this.id));            uc.refreshSave(primaryKey);            if (conn != null) {                conn.close();                conn = null;            }        }        return rowcount>0? true:false;    }    private long id;    private String typeCode;    public InfoDb getInfoDb(long id) {        return (InfoDb)getObjectDb(new Long(id));    }    public void load() {        ResultSet rs = null;        Conn conn = new Conn(connname);        try {            PreparedStatement ps = conn.prepareStatement(this.QUERY_LOAD);            ps.setLong(1, id);            primaryKey.setValue(new Long(id));            rs = conn.executePreQuery();            if (rs.next()) {                typeCode = rs.getString(1);                userName = rs.getString(2);                addDate = DateUtil.parse(rs.getString(3));                loaded = true;            }        } catch (SQLException e) {            logger.error("load:" + e.getMessage());        }        finally {            if (conn!=null) {                conn.close();                conn = null;            }        }    }    public Vector list(int start, int end, String userName) {        String sql = "select id from " + this.tableName + " where userName=" + StrUtil.sqlstr(userName) + " order by addDate desc";        return list(sql, start, end);    }    public void setId(long id) {        this.id = id;    }    public long getId() {        return id;    }    public void setTypeCode(String typeCode) {        this.typeCode = typeCode;    }    public String getTypeCode() {        return typeCode;    }    public void setUserName(String userName) {        this.userName = userName;    }    public String getUserName() {        return userName;    }    public String getTypeName() {        Leaf lf = new Leaf();        lf = lf.getLeaf(typeCode);        if (lf==null)            return "";        else            return lf.getName();    }    public java.util.Date getAddDate() {        return this.addDate;    }    private String userName;    private java.util.Date addDate;}

⌨️ 快捷键说明

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