更新:我尝试了以下建议,但仍然无法正常工作。尝试employeeid = 1时,它确实说成功,但是进入mysql命令行,它仍然在那里显示记录。
我尝试查看不同的帖子并且我的插入工作但由于某种原因我无法使用删除功能。
我正在尝试删除记录,但不断收到错误消息。运行 mysql 和 netbeans。请帮忙,谢谢。
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
statement.executeUpdate("INSERT INTO `abcinc`.`employees`"
+ "(`EmployeeID`,`First_Name`,`Last_Name`,`Birthday`,`Dept_Name`)VALUES("
+ "'" + jTextField1.getText() + "',"
+ "'" + jTextField2.getText() + "',"
+ "'" + jTextField3.getText() + "',"
+ "'" + jTextField4.getText() + "',"
+ "'" + jTextField5.getText() + "');");
JOptionPane.showMessageDialog(null, "Successful Update!!!", "Database Messages",
JOptionPane.OK_OPTION);
}
catch(SQLException error){
JOptionPane.showMessageDialog( null, error.getMessage(), "Database Messages",
JOptionPane.ERROR_MESSAGE );
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
statement.executeUpdate("DELETE FROM `abcinc`.`employees`"
+ "WHERE (`EmployeeID`,`First_Name`,`Last_Name`,`Birthday`,`Dept_Name`)VALUES("
+ "'" + jTextField1.getText() + "',"
+ "'" + jTextField2.getText() + "',"
+ "'" + jTextField3.getText() + "',"
+ "'" + jTextField4.getText() + "',"
+ "'" + jTextField5.getText() + "');");
JOptionPane.showMessageDialog(null, "Successful Update!!!", "Database Messages",
JOptionPane.OK_OPTION);
}
catch(SQLException error){
JOptionPane.showMessageDialog( null, error.getMessage(), "Database Messages",
JOptionPane.ERROR_MESSAGE );
}
}