示例#1
0
 public DbHotel(HotelBean hb) {
   this.hotelId1 = hb.getHotelId();
   this.hotelName1 = hb.getHotelName();
   this.description1 = hb.getDescription();
   this.location1 = hb.getLocation();
   this.rating1 = hb.getRating();
   this.roomType1 = hb.getRoomType();
   this.costPerRoom1 = hb.getCostPerRoom();
 }
示例#2
0
  public void EditedHotelDb(HotelBean bean) {
    int id = bean.getHotelId(); //
    System.out.println("Id = " + id);
    System.out.println("yup");
    Connection connection = null;
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
      connection =
          DriverManager.getConnection(
              "jdbc:oracle:thin:@172.16.68.55:1521:orcl1", "team5", "collabera");
      System.out.println("yup");
      PreparedStatement preparedStatementAdd =
          connection.prepareStatement(
              "update hotels set hotel_name = ?,"
                  + "hotel_location=?,hotel_description=?,hotel_rating=?,room_type=?, cost_per_room=? where hotel_id = "
                  + id);

      /* System.out.println(bean.getPackageName());
      System.out.println(bean.getDestination());
      System.out.println(bean.getDescription());
      System.out.println(bean.getHotelId());
      System.out.println(bean.getNumOfDays());
      System.out.println(bean.getHolidayType());
      System.out.println(bean.getCostPerPerson());
      System.out.println(bean.getPackageId());*/

      preparedStatementAdd.setString(1, bean.getHotelName());
      preparedStatementAdd.setString(2, bean.getDescription());
      preparedStatementAdd.setString(3, (bean.getLocation()));
      preparedStatementAdd.setInt(4, (bean.getRating()));
      preparedStatementAdd.setString(5, bean.getRoomType());
      preparedStatementAdd.setInt(6, (bean.getCostPerRoom())); //
      System.out.println("yup");
      int n = preparedStatementAdd.executeUpdate();
      System.out.println(n);
      System.out.println("yup");
      if (n != 0) {
        System.out.println("true");
      } else {
        System.out.println("true");
      }
      preparedStatementAdd.close();

    } catch (Exception exception) {
      System.out.println(exception);
    }
  }