/** Persist Saves the post to the database, this function will create a new database connection */ public void Persist() { PreparedStatement pstmt = null; Connection conn = null; try { conn = DB.getConnection(); String sql = "UPDATE " + User.dquote(Post.POST); sql += " set " + Post.CONTENT + " = ?, "; sql += Post.TYPE + " = ?, "; sql += Post.TIMESTAMP + " = ?, "; sql += Post.USER_ID + " = ?, "; sql += Post.WALL_ID + " = ?, "; sql += "where " + Post.POST_ID + " = ?"; Logger.debug("Generated update: [%s]", sql); pstmt = conn.prepareStatement(sql); pstmt.setString(1, this.content); pstmt.setString(2, this.type); pstmt.setTimestamp(3, this.time_stamp); pstmt.setLong(4, this.user_ID); pstmt.setLong(5, this.wall_ID); pstmt.setLong(6, this.post_ID); pstmt.executeUpdate(); pstmt.close(); conn.close(); } catch (SQLException e) { // Attempt to close the connection Logger.debug("Error while persisting Post"); if (conn != null) { try { conn.close(); } catch (Exception x) { Logger.debug("Error while closing connection during exception", x); } } } }