}
return flightList;
}
public Flight showInformation(Long id) {
Flight flight = new Flight();
try {
String query = "SELECT Airports.Name AS Name FROM Flights INNER JOIN Airports ON Flights.DepartureAirport=Airports.Id WHERE Flights.Id=?";
PreparedStatement statement = connection.prepareStatement(query);
statement.setLong(1, id);
ResultSet resultSet = statement.executeQuery();
resultSet.next();
String departureAirportName = resultSet.getString("Name");
query = "SELECT Flights.departureAirport AS departureAirport, Flights.destinationAirport AS destinationAirport, Flights.Id, Flights.t, Flights.Gate, Airports.Name AS Name FROM Flights INNER JOIN Airports" +
" ON Airports.Id=Flights.destinationAirport WHERE Flights.Id=?";
statement = connection.prepareStatement(query);
statement.setLong(1, id);
resultSet = statement.executeQuery();
resultSet.next();
flight.setDepartureAirport(new Airport());
flight.getDepartureAirport().setId(resultSet.getLong("departureAirport"));
flight.getDepartureAirport().setName(departureAirportName);
flight.setId(resultSet.getLong("id"));
flight.setDestinationAirport(new Airport());
flight.getDestinationAirport().setId(resultSet.getLong("destinationAirport"));
flight.getDestinationAirport().setName(resultSet.getString("Name"));
flight.setGate(resultSet.getInt("Gate"));
flight.setT(resultSet.getTimestamp("t"));
} catch(SQLException e) {
logs.info("Ошибка выборки "+e);
}
return flight;
}