Пример #1
0
  public static int run(int pachumeId) {

    int commentCount = 0;
    try {

      DataBaseConnection countComments_db = new DataBaseConnection();
      countComments_db.connect();
      String countComments_sql =
          "SELECT COUNT(*) AS commentCount FROM comment WHERE pachumeId = " + pachumeId;
      ResultSet countComments_rs = countComments_db.execSQL(countComments_sql);

      if (countComments_rs.next()) {
        commentCount = countComments_rs.getInt("commentCount");
      }
      countComments_db.close();
    } catch (Exception e) {
      System.out.print(e);
    }

    return commentCount;
  } // </editor-fold>
Пример #2
0
  // <editor-fold defaultstate="collapsed" desc="removeFriend">
  public static boolean run(int userId, int friendId) {

    boolean isDeFriend = false;

    try {
      DataBaseConnection deFriend_db;
      deFriend_db = new DataBaseConnection();
      deFriend_db.connect();

      String deFriend_sql =
          "DELETE FROM contact WHERE userId = " + userId + " AND friendId = " + friendId;
      deFriend_db.execUpdate(deFriend_sql);

      deFriend_db.close();

      isDeFriend = true;

    } catch (Exception e) {
      isDeFriend = false;
    }

    return isDeFriend;
  } // </editor-fold>