在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());
}
}
}