0
Java 및 MySQL을 사용하면 while 루프는 쿼리를 만족하는 마지막 레코드 만 반환합니다. 쿼리는 MySQL Workbench에서 쿼리를 실행하는 것에 따라 정확 해 보입니다. 둘 이상의 레코드가 리턴되어야합니다.JDBC, SELECT 문은 마지막 레코드 만 반환합니다.
Statement statement2 = connection.createStatement();
String entryCrew = crewFlight.getText();
String s2 = "select airemployee.eid, airemployee.Fname, airemployee.lname, airemployee.phone, airemployee.JobDescription, airemployee.AircraftID, airemployee.salary, flightno\n" +
"from airemployee inner join flight on airemployee.aircraftID = flight.aircraftID where flightno = '"+entryCrew+"'";
ResultSet rs2 = statement2.executeQuery(s2);
while (rs2.next()){
outputArea.setText("EID:"+rs2.getInt("EID")+"---"+"First Name:"+rs2.getString("FName")+"---"+"Last Name:"+rs2.getString("LName")+"---"+"Phone:"+rs2.getString("Phone")+"---"+"Job:"+rs2.getString("JobDescription")+"---"+"AircraftID:"+rs2.getInt("AircraftID")+"---"+"Salary:"+rs2.getInt("Salary"));
}
}
catch (Exception exc){
JOptionPane.showMessageDialog(null, exc);
}
}