0
JavaおよびMySQLを使用すると、whileループはクエリを満たす最後のレコードのみを返します。クエリは、MySQL Workbenchで実行されていることに基づいて正しく表示されます。複数のレコードが返される必要があります。JDBC、SELECT文は最後のレコードのみを返します。
ステートメントステートメント2 = 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);
}
}