这段代码:
private void btnDeleteRecordActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
rs.deleteRow();
stmt.close();
rs.close();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql = "SELECT * FROM Workers";
rs = stmt.executeQuery(sql);
rs.next();
int id_col = rs.getInt("ID");
String id = Integer.toString(id_col);
String first = rs.getString("First_Name");
String last = rs.getString("Last_Name");
String job = rs.getString("Job_Title");
textID.setText(id);
textFirstName.setText(first);
textLastName.setText(last);
textJobTitle.setText(job);
} catch (SQLException err) {
// System.out.println(err.getMessage());
JOptionPane.showMessageDialog(Workers.this, err.getMessage());
}
}
从数据库中删除一行后,程序冻结。我希望该程序能够在删除按钮 te 下一个和上一个按钮工作后工作。
我用过:http: //www.homeandlearn.co.uk/java/delete_a_record_from_a_database.html