Package dao.tro

Examples of dao.tro.Flight


        try {
            trui = Long.parseLong(request.getParameter("flightNumber"));
        } catch (NumberFormatException e) {
            log.info("I catch an exception "+e);
        }
        Flight flight = factory.getFlightDAO().showInformation(trui);
        flight.setDepartureAirport(factory.getAirportDAO().loadCountryName(flight.getDepartureAirport()));
        flight.setDestinationAirport(factory.getAirportDAO().loadCountryName(flight.getDestinationAirport()));
        ActionResult actionResult = new ActionResult();
        actionResult.setUrlAddress("flt/ShowFlightInformation.jsp");
        if (flight!=null) {
            actionResult.setUrlAddress("/flt/ShowFlightInformation.jsp");
        } else {
View Full Code Here


            st.setLong(1, departureAirportId);
            resultSet = st.executeQuery();
            //заносим их в список
            int listIterator = 0;
            while (resultSet.next()) {
                flightList.add(new Flight());
                flightList.get(listIterator).setId(resultSet.getLong("Id"));
                flightList.get(listIterator).setDepartureAirport(new Airport());
                flightList.get(listIterator).getDepartureAirport().setId(departureAirportId);
                flightList.get(listIterator).getDepartureAirport().setName(departureAirportName);
                flightList.get(listIterator).setDestinationAirport(new Airport());
View Full Code Here

            st.setLong(1, destinationAirportId);
            resultSet = st.executeQuery();
            //заносим их в список
            int listIterator =0;
            while (resultSet.next()) {
                flightList.add(new Flight());
                flightList.get(listIterator).setId(resultSet.getLong("Id"));
                flightList.get(listIterator).setDepartureAirport(new Airport());
                flightList.get(listIterator).getDepartureAirport().setId(resultSet.getLong("departureAirport"));
                flightList.get(listIterator).getDepartureAirport().setName(resultSet.getString("AName"));
                flightList.get(listIterator).setDestinationAirport(new Airport());
View Full Code Here

        }
        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;
    }
View Full Code Here

            PreparedStatement st = connection.prepareStatement(query);
            ResultSet destinationResultSet = st.executeQuery();
            //создаем список из [flightCount] аэропортов
            int listIterator =0;
            while ((departureResultSet.next())&&(destinationResultSet.next())&&(listIterator<flightCount)) {
                flightList.add(new Flight());
                flightList.get(listIterator).setId(destinationResultSet.getLong("Id"));
                flightList.get(listIterator).setDepartureAirport(new Airport());
                flightList.get(listIterator).getDepartureAirport().setId(departureResultSet.getLong("AID"));
                flightList.get(listIterator).getDepartureAirport().setName(departureResultSet.getString("Name"));
                flightList.get(listIterator).setDestinationAirport(new Airport());
View Full Code Here

TOP

Related Classes of dao.tro.Flight

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.