你好朋友我正在尝试在我的 Jave Gui 应用程序中显示记录我已经编写了一些代码它可以工作但是当我单击下一步按钮时它会显示最后一条记录。有没有其他方法可以查看中间存在的记录,请帮忙。
private void bt_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 [box_no],[weight],[note_state],[dm_state],[1],[2],[5],[10],[20],[50],[100],[500],[1000] FROM [CNV].[dbo].[soil_det] where rm_id=?");
ResultSet rs;
String rm = tf_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);
txtboxno.setText(rs.getString("box_no"));
txtRe1.setText(rs.getString("1"));
txtRs2.setText(rs.getString("2"));
txtRs5.setText(rs.getString("5"));
txtRs10.setText(rs.getString("10"));
txtRs20.setText(rs.getString("20"));
txtRs50.setText(rs.getString("50"));
txtRs100.setText(rs.getString("100"));
txtRs500.setText(rs.getString("500"));
txtRs1000.setText(rs.getString("1000"));
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}`enter code here`