此代码仅从数据库中检索 1 条记录。
如何使用下一步按钮从数据库中检索其余记录
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;
}