예제 #1
0
  public int getReservationCnt(int product_id) {
    connect();
    ArrayList<reservation> list = new ArrayList<reservation>();
    int cnt = 0;
    try {

      pstmt = con.prepareStatement("select * from reservation where product_id = " + product_id);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        reservation r = new reservation();
        r.setReserve_id(rs.getInt("reserve_id"));
        r.setReserve_date(rs.getString("reserve_date"));
        r.setPeople_num(rs.getInt("people_num"));
        r.setPeople_id(rs.getString("people_id"));
        r.setProduct_id(rs.getInt("product_id"));
        r.setSeat(rs.getInt("seat"));
        r.setPassport_num(rs.getString("passport_num"));
        cnt++;
        list.add(r);
        result++;
      }
      this.setResult(result);
      rs.close();

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      disconnect();
    }
    return cnt;
  }
예제 #2
0
  public ArrayList<reservation> getReservation() {
    connect();
    ArrayList<reservation> list = new ArrayList<reservation>();

    try {

      if (this.getOrd().equals("select")) {
        pstmt = con.prepareStatement(SQL);
        ResultSet rs = pstmt.executeQuery();

        while (rs.next()) {
          reservation r = new reservation();
          r.setReserve_id(rs.getInt("reserve_id"));
          r.setReserve_date(rs.getString("reserve_date"));
          r.setPeople_num(rs.getInt("people_num"));
          r.setPeople_id(rs.getString("people_id"));
          r.setProduct_id(rs.getInt("product_id"));
          r.setSeat(rs.getInt("seat"));
          r.setPassport_num(rs.getString("passport_num"));

          list.add(r);
          result++;
        }
        this.setResult(result);
        rs.close();
      } else {
        pstmt = con.prepareStatement(SQL);
        result = pstmt.executeUpdate();
        this.setResult(result);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      disconnect();
    }
    return list;
  }