public static boolean updateFlight(Flight newFlight, Flight oldFlight){
        boolean result = false;

        PreparedStatement pstmt;
        try {
            pstmt = con.prepareStatement("Update flight set flightnumber = ?, airportfrom = ?, airportdestination = ?, pilot = ?, copilot = ?, `date` = ?, plane = ?, returnflight = ? where flightnumber = ? ;");

            pstmt.setInt(1, newFlight.getNumber());
            pstmt.setString(2, newFlight.getFrom().getCode());
            pstmt.setString(3, newFlight.getDestination().getCode());

            pstmt.setInt(4, newFlight.getPilots()[0].getNumber());
            pstmt.setInt(5, newFlight.getPilots()[1].getNumber());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            String date = sdf.format(newFlight.getDate());
            pstmt.setString(6, date);
            pstmt.setInt(7, newFlight.getPlane().getNumber());
			if(newFlight.getReturnFlight() == 0){
				pstmt.setNull(8, java.sql.Types.INTEGER);
			}else{
				pstmt.setInt(8, newFlight.getReturnFlight());
			}
            pstmt.setInt(9, oldFlight.getNumber());

           
            int x = pstmt.executeUpdate();

            if(x == 1){
                result = true;
            }

            pstmt = con.prepareStatement("DELETE FROM `flightstaff` WHERE `flight` = " + newFlight.getNumber() + ";");
            pstmt.executeUpdate();

            pstmt = con.prepareStatement("INSERT INTO `flightstaff` VALUES(?, ?);");
            pstmt.setInt(1, newFlight.getNumber());

            for(Staff s : oldFlight.getOtherPersonal()){
                pstmt.setInt(2, s.getNumber());
                pstmt.executeUpdate();
            }

            pstmt = con.prepareStatement("DELETE FROM `flightstops` WHERE `flight` = " + newFlight.getNumber() + ";");
            pstmt.executeUpdate();

            pstmt = con.prepareStatement("INSERT INTO `flightstops` VALUES(?, ?);");
            pstmt.setInt(1, newFlight.getNumber());

            for(Airport a : oldFlight.getStops()){
                pstmt.setString(2, a.getCode());
                pstmt.executeUpdate();
            }
        } catch (SQLException ex) {
            Logger.getLogger(DatabaseConnectie.class.getName()).log(Level.SEVERE, null, ex);
        }
        return result;
    }