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

📄 dbforum.java

📁 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar 天乙代码src_531.rar
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            " and  DelSign = 0 and " + this.getSearchCon() + " like '%" +
            this.getSearchText() + "%' order by PostTime desc";
        this.pages.setTotals(this.getPostNum(myDB, key));
        this.pages.doPageBreak();
        this.sListPageBreak = this.pages.getListPageBreak();
        this.pages.setSQL(strSQL);
        myDB.prepareStatement(this.pages.getSQLString("ID"));
        rs = myDB.executeQuery();
      }
      if (key.equals("elite")) {
        SQL = "select * from " + this.myForumInfo.getTablename() +
            " where Elite = ? and EliteID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, this.myForumInfo.getElite());
        myDB.setLong(2, this.myForumInfo.getEliteID());
        rs = myDB.executeQuery();
      }
      while (rs.next()) {
        aForumInfo = new ForumInfo();
        aForumInfo.setID(rs.getLong("ID"));
        aForumInfo.setID1(rs.getLong("ID1"));
        aForumInfo.setID2(rs.getLong("ID2"));
        aForumInfo.setBoardID(rs.getLong("BoardID"));
        aForumInfo.setBoardName(rs.getString("BoardName"));
        aForumInfo.setReNum(rs.getInt("ReNum"));
        aForumInfo.setFace(rs.getInt("Face"));
        aForumInfo.setUserID(rs.getLong("UserID"));
        aForumInfo.setUserName(rs.getString("UserName"));
        aForumInfo.setTitle(rs.getString("Title"));
        aForumInfo.setDetail(rs.getString("Detail"));
        aForumInfo.setSign(rs.getString("Sign"));
        aForumInfo.setArtSize(rs.getInt("ArtSize"));
        aForumInfo.setEmail_Inform(rs.getInt("Email_Inform"));
        aForumInfo.setMsg_Inform(rs.getInt("Msg_Inform"));
        aForumInfo.setClick(rs.getInt("Click"));
        aForumInfo.setPostTime(rs.getLong("PostTime"));
        aForumInfo.setLastTime(rs.getLong("LastTime"));
        aForumInfo.setIPAddress(rs.getString("IPAddress"));
        aForumInfo.setVtime(rs.getString("vtime"));
        aForumInfo.setIsNew(rs.getInt("IsNew"));
        aForumInfo.setNickName(rs.getString("NickName"));
        aForumInfo.setElite(rs.getLong("Elite"));
        aForumInfo.setEliteID(rs.getLong("EliteID"));
        aForumInfo.setAgree(rs.getInt("Agree"));
        aForumInfo.setBeAgainst(rs.getInt("BeAgainst"));
        aForumInfo.setCanNotDel(rs.getInt("CanNotDel"));
        aForumInfo.setDelSign(rs.getInt("DelSign"));
        aForumInfo.setDelUserID(rs.getLong("DelUserID"));
        aForumInfo.setDelUserName(rs.getString("DelUserName"));
        aForumInfo.setDelTime(rs.getLong("DelTime"));
        aForumInfo.setDelIP(rs.getString("DelIP"));
        aForumInfo.setCanNotRe(rs.getInt("CanNotRe"));
        aForumInfo.setAmend(rs.getString("Amend"));
        aForumInfo.setDoEliteName(rs.getString("DoEliteName"));
        aForumInfo.setDoEliteTime(rs.getLong("DoEliteTime"));
        aForumInfo.setHavePic(rs.getInt("HavePic"));
        aForumInfo.setPicName(rs.getString("PicName"));
        aForumInfo.setLastPostUserName(rs.getString("LastPostUserName"));
        aForumInfo.setLastPostTitle(rs.getString("LastPostTitle"));
        aForumInfo.setIsTop(rs.getInt("IsTop"));
        aForumInfo.setIsB(rs.getInt("IsB"));
        aForumInfo.setIsLock(rs.getInt("IsLock"));
        if (load) {
          FileLoadCache flc = new FileLoadCache(String.valueOf(aForumInfo.
              getID()), aForumInfo);
          FileLoad fl = flc.get();
          aForumInfo.setDetailText(fl.getContent());
        }

        alist.add(aForumInfo);
        aForumInfo = null;
      }
      return alist;
    }
    catch (SQLException e) {
      throw new ObjectException(e.toString());
    }
    finally {
      try {
        if (rs != null) {
          rs.close();
          rs = null;
        }
      }
      catch (SQLException e) {
      }
      try {
        if (myDB != null) {
          myDB.close();
        }
      }
      catch (SQLException e) {
      }
    }
  }

  public void insertDB(TranContext myDB) throws ObjectException {
    try {
      SQL = "insert into " + this.myForumInfo.getTablename() + " (ID,ID1,ID2,BoardID,BoardName,Face,UserID,UserName,Title,Detail,Sign,ArtSize,Email_Inform,"
          + "Msg_Inform,PostTime,LastTime,IPAddress,IsNew,NickName,HavePic,PicName) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
      myDB.prepareStatement(SQL);
      myDB.setLong(1, this.myForumInfo.getID());
      myDB.setLong(2, this.myForumInfo.getID1());
      myDB.setLong(3, this.myForumInfo.getID2());
      myDB.setLong(4, this.myForumInfo.getBoardID());
      myDB.setString(5, this.myForumInfo.getBoardName());
      myDB.setInt(6, this.myForumInfo.getFace());
      myDB.setLong(7, this.myForumInfo.getUserID());
      myDB.setString(8, this.myForumInfo.getUserName());
      myDB.setString(9, this.myForumInfo.getTitle());
      myDB.setString(10, this.myForumInfo.getDetail());
      myDB.setString(11, this.myForumInfo.getSign());
      myDB.setInt(12, this.myForumInfo.getArtSize());
      myDB.setInt(13, this.myForumInfo.getEmail_Inform());
      myDB.setInt(14, this.myForumInfo.getMsg_Inform());
      myDB.setLong(15, this.myForumInfo.getPostTime());
      myDB.setLong(16, this.myForumInfo.getLastTime());
      myDB.setString(17, this.myForumInfo.getIPAddress());
      myDB.setInt(18, this.myForumInfo.getIsNew());
      myDB.setString(19, this.myForumInfo.getNickName());
      myDB.setInt(20, this.myForumInfo.getHavePic());
      myDB.setString(21, this.myForumInfo.getPicName());
      myDB.executeUpdate();
    }
    catch (SQLException e) {
      throw new ObjectException(e.toString());
    }
    finally {
      try {
        if (myDB != null) {
          myDB.close();
        }
      }
      catch (SQLException e) {
      }
    }
  }

  public void updateDB(TranContext myDB, String key) throws ObjectException {
    try {
      if (key.equals("click")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set Click = Click + 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("addReNum")) {
        SQL = "update " + this.myForumInfo.getTablename() + " set ReNum = ReNum + 1,LastTime = ?,LastPostUserName=?,LastPostTitle=? where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getLastTime());
        myDB.setString(2, myForumInfo.getLastPostUserName());
        myDB.setString(3, myForumInfo.getLastPostTitle());
        myDB.setLong(4, myForumInfo.getID());
      }
      if (key.equals("canotre")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set CanNotRe = 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("lock")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set IsLock = ? where ID2 = ?";
        myDB.prepareStatement(SQL);
        myDB.setInt(1, this.myForumInfo.getIsLock());
        myDB.setLong(2, this.myForumInfo.getID2());
      }
      if (key.equals("cannotdel")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set CanNotDel = 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("settop")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set IsTop = ? where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setInt(1, myForumInfo.getIsTop());
        myDB.setLong(2, myForumInfo.getID());
      }
      if (key.equals("delpic")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set HavePic = 0 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("delaPost")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set DelSign = 1,DelUserID = ?,DelUserName=?,DelTime=?,DelIP=? where ID = ?";
        //Sys.log(SQL);
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getDelUserID());
        myDB.setString(2, myForumInfo.getDelUserName());
        myDB.setLong(3, myForumInfo.getDelTime());
        myDB.setString(4, myForumInfo.getDelIP());
        myDB.setLong(5, myForumInfo.getID());
      }
      if (key.equals("undel")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set DelSign = 0 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("decReNum")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set ReNum = ReNum - 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("incReNum")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set ReNum = ReNum + 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("zc")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set Agree = Agree + 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("fd")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set BeAgainst = BeAgainst + 1 where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getID());
      }
      if (key.equals("doelite")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set Elite = ?,DoEliteName = ?,DoEliteTime = ? where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getElite());
        myDB.setString(2, myForumInfo.getDoEliteName());
        myDB.setLong(3, myForumInfo.getDoEliteTime());
        myDB.setLong(4, myForumInfo.getID());
      }
      if (key.equals("change")) {
        SQL = "update " + this.myForumInfo.getTablename() + " set Face = ?,Title = ?,Detail = ?,Artsize = ?, IPAddress = ?, Amend = ? where ID = ?";
        myDB.prepareStatement(SQL);
        myDB.setInt(1, myForumInfo.getFace());
        myDB.setString(2, myForumInfo.getTitle());
        myDB.setString(3, myForumInfo.getDetail());
        myDB.setInt(4, myForumInfo.getArtSize());
        myDB.setString(5, myForumInfo.getIPAddress());
        myDB.setString(6, myForumInfo.getAmend());
        myDB.setLong(7, myForumInfo.getID());
      }
      if (key.equals("inDir")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set EliteID = ? where ID in (" +
            this.sDelPostIDs + ")";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getEliteID());
      }
      if (key.equals("outDir")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set Elite = 0,EliteID = 0 where ID in (" + this.sDelPostIDs + ")";
        myDB.prepareStatement(SQL);
        //myDB.setLong(1,myForumInfo.getEliteID());
      }
      if (key.equals("delEliteDir")) {
        SQL = "update " + this.myForumInfo.getTablename() +
            " set EliteID = ? where EliteID = ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, myForumInfo.getEliteID());
        myDB.setLong(2, myForumInfo.getElite());
      }
      myDB.executeUpdate();

    }
    catch (SQLException e) {
      throw new ObjectException(e.toString());
    }
    finally {
      try {
        if (myDB != null) {
          myDB.close();
        }
      }
      catch (SQLException e) {
      }
    }
  }

  public void delDB(TranContext myDB, String key) throws ObjectException {
    try {
      if (key.equals("delwaste")) {
        SQL = "delete from " + this.myForumInfo.getTablename() +
            " where ID in (" + this.sDelPostIDs + ") and DelTime < ?";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, (Util.getaLongTime() - 604800000));
      }
      if (key.equals("delall")) {
        SQL = "delete from " + this.myForumInfo.getTablename() +
            " where BoardID = ? and DelTime < ? and DelSign = 1";
        myDB.prepareStatement(SQL);
        myDB.setLong(1, this.myForumInfo.getBoardID());
        myDB.setLong(2, (Util.getaLongTime() - 604800000));
      }
      myDB.executeUpdate();
    }
    catch (SQLException e) {
      throw new ObjectException(e.toString());
    }
    finally {
      try {
        if (myDB != null) {
          myDB.close();
        }
      }
      catch (SQLException e) {
      }
    }
  }

}

⌨️ 快捷键说明

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