此代碼僅從數據庫中檢索1條記錄。無法從記錄集檢索多個結果
如何使用Next按鈕
public void Next()
{
Connection con=null;
ResultSet rs=null;
try {
con=DBConnection();
Statement stmt=con.createStatement();
rs= stmt.executeQuery("select * from info where id=1");
while(rs.next())
{
t1.setText(rs.getString("Name"));
t2.setText(rs.getString("Branch"));
}
} catch (Exception e) {
// TODO: handle exception
}finally{
try {
rs.close();
} catch (SQLException err) {
JOptionPane.showMessageDialog(btnnext, err.getMessage());
// TODO: handle exception
}
}
//return rs;
}
在你的循環中,你總是改變相同的對象t1和t2。所以只有最後一行很重要。 –
但是點擊下一步按鈕它從數據庫中只取出1條記錄.... – VVV
如何取回其餘記錄 – VVV