public void addOneComment(DocComment docComment) throws DocCommentManagerException {
    // TODO Auto-generated method stub
    PreparedDBUtil preparedDB = new PreparedDBUtil();
    DBUtil dbUitl = new DBUtil();

    String sql =
        "insert into td_cms_doc_comment(comment_id, doc_id,doc_comment,user_name,comtime,user_ip,src_comment_id,status) values(?, ?,?,?,?,?,?,?)";
    try {

      int id =
          (Integer)
              dbUitl.executeSelectForObject(executor.getSql("getCommentNextId"), Integer.class);
      preparedDB.preparedInsert(sql);
      preparedDB.setInt(1, id);
      preparedDB.setInt(2, docComment.getDocId());
      preparedDB.setClob(3, docComment.getDocComment(), "doc_comment");
      preparedDB.setString(4, docComment.getUserName());
      preparedDB.setTimestamp(5, new Timestamp(new Date().getTime()));
      preparedDB.setString(6, docComment.getUserIP());
      if (docComment.getSrcCommentId() == 0) preparedDB.setNull(7, Types.NUMERIC);
      else preparedDB.setInt(7, docComment.getSrcCommentId());
      preparedDB.setInt(8, docComment.getStatus());
      preparedDB.executePrepared();
    } catch (SQLException e) {
      e.printStackTrace();
      throw new DocCommentManagerException("新评论插入失败!" + e.getMessage());
    } finally {
      preparedDB.resetPrepare();
    }
  }
示例#2
0
  private boolean exist(Connection con, long curValue) throws SQLException {
    String select =
        "select count(1) from " + this.tableName + " where " + this.primaryKeyName + "=?";
    PreparedDBUtil dbUtil = new PreparedDBUtil();
    try {
      //			String update = "update tableinfo set table_id_value=" + this.curValue +" where
      // table_name='"+ tableName.toLowerCase() + "' and table_id_value <" + this.curValue  ;
      dbUtil.preparedSelect(this.dbname, select);
      if (this.metaType.equals("int")
          || this.metaType.equals("java.lang.Integer")
          || this.metaType.equals("java.lang.integer")
          || this.metaType.equalsIgnoreCase("integer")) {
        dbUtil.setInt(1, (int) curValue);
      } else if (this.metaType.equals("java.lang.Long")
          || this.metaType.equals("java.lang.long")
          || this.metaType.equalsIgnoreCase("long")) {
        dbUtil.setLong(1, curValue);
      } else if (this.metaType.equals("java.lang.String")
          || this.metaType.equalsIgnoreCase("string")) {

        dbUtil.setString(1, this.prefix + curValue + "");
      } else {
        dbUtil.setString(1, this.prefix + curValue + "");
      }

      dbUtil.executePrepared(con);
      if (dbUtil.getInt(0, 0) > 0) return true;
    } catch (SQLException e1) {

      e1.printStackTrace();
      throw e1;

    } catch (Exception e1) {

      e1.printStackTrace();
      throw new SQLException(e1.getMessage());
    } finally {
      dbUtil.resetPrepare();
    }
    return false;
  }
  public void addDocCommentImpeach(CommentImpeach commentImpeach)
      throws DocCommentManagerException {
    PreparedDBUtil preparedDB = new PreparedDBUtil();
    String sql =
        "insert into td_cms_doccom_impeachinfo(comment_id,impeacher,email,reason,descriptioninfo,comtime) values(?,?,?,?,?,?)";
    try {
      preparedDB.preparedInsert(sql);

      preparedDB.setInt(1, commentImpeach.getCommentId());
      preparedDB.setString(2, commentImpeach.getImpeacher());
      preparedDB.setString(3, commentImpeach.getEmail());
      preparedDB.setInt(4, commentImpeach.getReason());
      preparedDB.setString(5, commentImpeach.getDescription());
      preparedDB.setTimestamp(6, new Timestamp(new Date().getTime()));
      preparedDB.executePrepared();
    } catch (SQLException e) {
      e.printStackTrace();
      throw new DocCommentManagerException("举报信息插入数据库失败!" + e.getMessage());
    } finally {
      preparedDB.resetPrepare();
    }
  }