/** * @param rs * @return object RequestRoom * @throws SQLException */ private RequestRoom getRequestRoom(ResultSet rs) throws SQLException { User user = new User(); user.setId(rs.getInt("users.id")); Client client = new Client(); client.setUser(user); client.setLastname(rs.getString(ColumnNames.LASTNAME)); client.setFirstname(rs.getString(ColumnNames.FIRSTNAME)); RequestRoom requestRoom = new RequestRoom(); requestRoom.setId(rs.getInt("requests.id")); requestRoom.setClient(client); requestRoom.setAmountOfBed(rs.getInt(ColumnNames.AMOUNT_OF_BED)); requestRoom.setClassOfRoom(rs.getString(ColumnNames.CLASS)); requestRoom.setArrivalDate(rs.getDate(ColumnNames.ARRIVAL_DATE)); requestRoom.setDepartureDate(rs.getDate(ColumnNames.DEPARTURE_DATE)); return requestRoom; }
/** * @param id * @return object RequestRoom * @throws SQLException */ public RequestRoom get(Integer id) throws SQLException { Connection c = MySQLDatabase.getConnection(); PreparedStatement s = c.prepareStatement(DB_GET_REQUEST); s.setInt(1, id); ResultSet rs = s.executeQuery(); RequestRoom requestRoom = new RequestRoom(); if (rs.next()) { requestRoom.setId(id); requestRoom.setClassOfRoom(rs.getString(ColumnNames.CLASS)); requestRoom.setAmountOfBed(rs.getInt(ColumnNames.AMOUNT_OF_BED)); requestRoom.setDepartureDate(rs.getDate(ColumnNames.DEPARTURE_DATE)); requestRoom.setArrivalDate(rs.getDate(ColumnNames.ARRIVAL_DATE)); Client client = new Client(); User user = new User(); user.setId(rs.getInt(ColumnNames.USER_ID)); client.setUser(user); requestRoom.setClient(client); } MySQLDatabase.releaseConnection(c); return requestRoom; }