Ejemplo n.º 1
0
 public Comment addComment(int messageId, Comment comment) {
   String query =
       "insert into comment (\"commentMessage\", author, created, \"messageId\") values('"
           + comment.getCommentMessage()
           + "', '"
           + comment.getAuthor()
           + "', '"
           + comment.getCreated()
           + "', "
           + messageId
           + ")";
   db.addData(query);
   return comment;
 }
Ejemplo n.º 2
0
 public Comment getComment(String commentId) {
   Comment comment = new Comment();
   try {
     ResultSet rs = db.getData("comment", "id", commentId);
     while (rs.next()) {
       comment.setCommentMessage(rs.getString("commentMessage"));
       comment.setAuthor(rs.getString("author"));
       comment.setCreated(rs.getDate("created"));
     }
   } catch (SQLException e) {
     System.err.println("Exception on getComment : " + e);
     ;
   }
   return comment;
 }
Ejemplo n.º 3
0
 public Comment updateComment(int messageId, Comment comment) {
   String query =
       "update comment set \"commentMessage\" = '"
           + comment.getCommentMessage()
           + "', author = '"
           + comment.getAuthor()
           + "', created = '"
           + comment.getCreated()
           + "', \"messageId\" = '"
           + messageId
           + "' where id = '"
           + comment.getId()
           + "'";
   db.addData(query);
   return comment;
 }
Ejemplo n.º 4
0
 public List<Comment> getAllComments(int messageId) {
   try {
     ResultSet rs = db.getAllDatas("comment where \"messageId\" = " + messageId);
     while (rs.next()) {
       Comment comment = new Comment();
       comment.setId(rs.getInt("id"));
       comment.setCommentMessage(rs.getString("commentMessage"));
       comment.setAuthor(rs.getString("author"));
       comment.setCreated(rs.getDate("created"));
       comments.add(comment);
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return comments;
 }
Ejemplo n.º 5
0
 public Comment removeComment(int commentId, Comment comment) {
   String query = "delete from comment where id = '" + commentId + "'";
   db.addData(query);
   return comment;
 }