package RDG;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.sql.SQLException;

/**
 *
 * @author Marcel
 */
public class FlightCostFinder {

    /**
     * select all flight costs
     * @throws SQLException
     * @return List of FlightCost
     */
    public static List<FlightCost> SelectAll() throws SQLException {
        PreparedStatement s = DbContext.getConnection().prepareStatement("SELECT * from flight_costs");
        //System.out.println(s);
        ResultSet rs = s.executeQuery();
        List<FlightCost> res = new ArrayList<>();
        while (rs.next()) {
            FlightCost tmp = new FlightCost();
            tmp.setFlight_cost_id(rs.getInt("flight_cost_id"));
            tmp.setPrice_per_km(rs.getDouble("price_per_km"));
            res.add(tmp);
        }
        return res;
    }
    
}
