Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void setComment(Comment comment) {
- Connection con = null;
- try {
- con = JDBCConnectionFactory.getNewConnection();
- String sql = "INSERT INTO comments (comments_title, comments_body, comments.student_id, comments.post_id, comments_time_stamp)" + " values (?, ?, ?, ?, NOW())";
- PreparedStatement prep = con.prepareStatement(sql);
- prep.setString(1, comment.getCommentTitle());
- prep.setString(2, comment.getCommentBody());
- prep.setLong(3, comment.getStudentId());
- prep.setInt(4, comment.getPostId());
- prep.executeUpdate();
- } catch (SQLException e){
- e.printStackTrace();
- } finally {
- JDBCConnectionFactory.closeConnection(con);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement