Added ability to get sold houses and rented apartments
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -80,6 +80,54 @@ public class ORM {
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of sold houses.
|
||||
*
|
||||
* @return a list of houseIDs
|
||||
*/
|
||||
public List<Integer> getSoldHouses() {
|
||||
List<Integer> soldHouses = new ArrayList<>();
|
||||
|
||||
try {
|
||||
String selectSQL = "SELECT house FROM SALES";
|
||||
PreparedStatement pstmt = _connection.prepareStatement(selectSQL);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
soldHouses.add(rs.getInt("house"));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return soldHouses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list with the IDs of rented apartments.
|
||||
*
|
||||
* @return a list of apartmentIDs
|
||||
*/
|
||||
public List<Integer> getRentedApartments() {
|
||||
List<Integer> rentedApartments = new ArrayList<>();
|
||||
|
||||
try {
|
||||
String selectSQL = "SELECT apartment FROM RENTALS";
|
||||
PreparedStatement pstmt = _connection.prepareStatement(selectSQL);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
rentedApartments.add(rs.getInt("apartment"));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return rentedApartments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a select all query for estates.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user