public ListInfo getCommnetImpeachList(String sql, int offset, int maxItem) throws DocCommentManagerException { DBUtil db = new DBUtil(); try { db.executeSelect(sql, offset, maxItem); List tempList = new ArrayList(); ListInfo listInfo = new ListInfo(); for (int i = 0; i < db.size(); i++) { CommentImpeach commentImpeach = new CommentImpeach(); commentImpeach.setId(db.getInt(i, "id")); commentImpeach.setCommentId(db.getInt(i, "comment_id")); commentImpeach.setImpeacher(db.getString(i, "impeacher")); commentImpeach.setEmail(db.getString(i, "email")); commentImpeach.setReason(db.getInt(i, "reason")); commentImpeach.setDescription(db.getString(i, "descriptioninfo")); commentImpeach.setComtime(db.getDate(i, "comtime")); commentImpeach.setRepled(db.getInt(i, "replyed")); tempList.add(commentImpeach); } listInfo.setDatas(tempList); listInfo.setTotalSize(db.getTotalSize()); return listInfo; } catch (SQLException e) { e.printStackTrace(); throw new DocCommentManagerException("获取评论列表失败!" + e.getMessage()); } }
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(); } }