航班flightToUpdate
= null;
//如果机场代码存在,则为变量赋值
flightToUpdate = DatabaseOperations.getFlightByFlightNumber(columns [0]);
System.out.println(flightToUpdate);
if (flightToUpdate == null) {// If the location for the given airport code is not present, it needs to be added
Flight flightToAdd = new Flight();
flightToAdd.setFilghtNumber(columns[0]);
flightToAdd.setDepartureAirport(columns[1]);
flightToAdd.setDestinationAirport(columns[2]);
flightToAdd.setPrice(Double.parseDouble(columns[3]));
flightToAdd.setDatetime(df.parse(columns[4]));
flightToAdd.setPlane(columns[5]);
flightToAdd.setSeatsTaken(Integer.parseInt(columns[6]));
//Add to database
DatabaseOperations.AddFlight(flightToAdd);
} else {
System.out.println("Success4");
DatabaseOperations.UpdateFlight(flightToUpdate);
}`enter code here`