Beispiel #1
0
  public static final void unlikes(User user, Post post) {
    Connection connection = null;
    PreparedStatement stmt = null;
    String sql = " DELETE FROM luser_likes_post where luser_id = ? and post_id = ?";
    try {
      connection = DBConnection.getConnection();
      stmt = connection.prepareStatement(sql);
      stmt.setString(1, user.getId());
      stmt.setInt(2, post.getId());
      stmt.executeUpdate();
    } catch (SQLException ex) {
      Logger.getLogger(PostMapper.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      if (stmt != null)
        try {
          stmt.close();
        } catch (SQLException e1) {
          e1.printStackTrace();
        }

      if (connection != null) {
        try {
          connection.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
  }