Example #1
0
 public DbHotel(BeanSearchHotel hb) {
   this.location1 = hb.getLocation();
   this.rating1 = hb.getRating();
   this.roomType1 = hb.getRoomType();
   /*System.out.println(location1);
   System.out.println(rating1);
   System.out.println(roomType1);*/
 }
Example #2
0
  public void DbSearchHotel(BeanSearchHotel hb) throws Exception {
    System.out.println("In DB Function");
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection =
        DriverManager.getConnection(
            "jdbc:oracle:thin:@172.16.68.55:1521:orcl1", "team5", "collabera");
    // String str="select * from Hotelss where HOTEL_LOCATION=? and HOTEL_RATING=? and ROOM_TYPE=?";
    PreparedStatement stmt =
        connection.prepareStatement(
            "select * from Hotels where HOTEL_LOCATION=? and HOTEL_RATING=? and ROOM_TYPE=?");
    stmt.setString(1, location1);
    stmt.setInt(2, rating1);
    stmt.setString(3, roomType1);
    System.out.println(location1);
    System.out.println(rating1);
    System.out.println(roomType1);
    // int n=stmt.executeUpdate();
    // System.out.println(n);
    System.out.println("After Prepared");
    ArrayList a1 = new ArrayList();
    ArrayList a2 = new ArrayList();
    ArrayList a3 = new ArrayList();
    ArrayList a4 = new ArrayList();
    ArrayList a5 = new ArrayList();
    ArrayList a6 = new ArrayList();
    ArrayList a7 = new ArrayList();
    ResultSet rs1;
    rs1 = stmt.executeQuery();
    /*System.out.println(location1);
    System.out.println(rating1);
    System.out.println(roomType1);*/
    // int n=rs1.getRow();
    // System.out.println(n);
    // rs1.next();

    // System.out.println(rs1.getString(2));
    while (rs1.next()) {
      Integer i = new Integer(rs1.getInt(1));
      System.out.println(rs1.getInt(1));
      a1.add(i);
      a2.add(rs1.getString(2));
      System.out.println(rs1.getString(2));
      a3.add(rs1.getString(3));
      System.out.println(rs1.getString(3));
      a4.add(rs1.getString(4));
      System.out.println(rs1.getString(4));
      System.out.println(rs1.getInt(5));
      System.out.println(rs1.getString(6));
      System.out.println(rs1.getInt(7));
      int i9 = rs1.getInt(5);
      Integer i5 = new Integer(i9);
      a5.add(i5);
      a6.add(rs1.getString(6));
      int i7 = rs1.getInt(7);
      Integer i8 = new Integer(i7);
      a7.add(i8);
    }
    System.out.println(a1.size());
    System.out.println(a2.size());
    System.out.println(a3.size());
    System.out.println(a4.size());
    System.out.println(a5.size());
    System.out.println(a6.size());
    System.out.println(a7.size());

    hb.setHotelId(a1);
    hb.setHotelName(a2);
    hb.setLocation1(a3);
    hb.setDescription(a4);
    hb.setRating1(a5);
    hb.setRoomType1(a6);
    hb.setCostPerRoom(a7);
    stmt.close();
    connection.close();
  }