Update: I tried the below suggestions, however it is still not working. When trying employeeid=1, it does say successful, however went going into mysql command line, it still shows the record there.
I tried looking at different posts and my insert works but for some reason i am unable to the delete function to work.
I am trying to delete a record but keep getting an error. Running mysql & netbeans. Please help, thank you.
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 );
}
}
DELETEis not correct (there's nothing likeVALUESfor delete).abcinc.employees" + "WHERE employeeid=1") So I am guessing it would/should look something like this?