Netbeans Java - 您的sql语法中有错误

时间:2017-03-19 12:03:15

标签: java jdbc

我在更新数据库时收到此错误。Error I'm getting

这就是我的数据库{@ 3}}

这是我的代码:

private void updatebtnActionPerformed(java.awt.event.ActionEvent evt){

    try{
    String mid = midtxt.getText();
    String fname = firstnametxt.getText();
    String lname = lastname.getText();
    String nic = nictxt.getText();
    String Address = addresstxt.getText();
    String Telephone = telephonetxt.getText();   


    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    jXDatePicker1.setFormats(dateFormat);
    DateFormat sysDate = new SimpleDateFormat("yyyy/MM/dd");
    String Dob  = sysDate.format(jXDatePicker1.getDate());



   String sql = "UPDATE `addmember` SET `FirstName`='"+fname+"',LastName`='"+lname+"',`NIC`='"+nic+"',`DOB`='"+Dob+"', `ADDRESS`='"+Address+"', `Telephone`='"+Telephone+"' WHERE MID='"+mid+"' ";
      try{
            Updater(sql);
            JOptionPane.showMessageDialog(null, "Values Updated");
        }
        catch( Exception ex){
            JOptionPane.showMessageDialog(null, ex);
        }
    }

    catch(Exception ex){
        JOptionPane.showMessageDialog(null, ex);
    }
}                                         

1 个答案:

答案 0 :(得分:1)

LastName之前缺少反引号。