我已经四处寻找这个问题的答案,但无济于事。当我编译它时,它只返回数据库中表的最后一行,而不是我期望的整个列的列表。我相信问题出在此处。如果我能列出该列中的所有内容,我将不胜感激。
String query = "SELECT contact_id, first_name, last_name FROM my_contacts";
ResultSet rs = statement.executeQuery(query);
while (rs.next())
{
System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3));
String name = rs.getString(2) + " " + rs.getString(3);
names = new JComboBox();
names.addItem(rs.getString("first_name"));
}//end while