在 java 中,如果我们想要使用向前和向后 2 个按钮来导航我们从执行查询中获得的结果集。我们可以通过什么方式执行此任务
private void nextActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getSource()==bt_previous){
DBUtil util = new DBUtil();
try {
Connection con = util.getConnection();
PreparedStatement stmt = con.prepareStatement("SELECT * FROM DETAILS where id=?");
ResultSet rs;
String rm = id.getText().trim();
stmt.setLong(1, Long.parseLong(rm));
rs = stmt.executeQuery();
while(rs.next()){
String a = rs.getString("weight");
txtboxwgt.setText(a);
String b = rs.getString("note_state");
cbnotstat.setSelectedItem(b);
String c = rs.getString("dm_state");
cbdmnstat.setSelectedItem(c);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}