mysql - SQL error while updating a row -


details of table under consideration :

enter image description here

code used updating rows :

 public void updateemployeedetails(employee employee) {      connection conn = jdbcutility.getconnection();      try {         string updatesql = "update employee_info set emp_name=?, location=?, email=?, dob=? emp_id=?";          preparedstatement ps = (preparedstatement)conn.preparestatement(updatesql);         ps.setstring(1, employee.getemp_name()); /*all attributes of employee object of type string */         ps.setstring(2, employee.getlocation());         ps.setstring(3, employee.getemail());         ps.setstring(4, employee.getdob());         ps.setstring(5, employee.getemp_id());         ps.executeupdate(updatesql);      } catch (sqlexception e) {         system.out.println(e.geterrorcode());         e.printstacktrace();     } } 

error received :

com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near '?, location=?, email=?, dob=?  emp_id=?' @ line 1 

can point out error because doubly checked possible error in query string? varchar(45) of mysql compatible java's string? i.e. ps.setstring(column_index, string) root cause of error?

debug 1 :

considering null possibility tried(in vain) following :

//  ps.setstring(1, employee.getemp_name()); //  ps.setstring(2, employee.getlocation()); //  ps.setstring(3, employee.getemail()); //  ps.setstring(4, employee.getdob()); //  ps.setstring(5, employee.getemp_id());  ps.setstring(1, "superman"); ps.setstring(2, "sky"); ps.setstring(3, "anymail@dooodle.com"); ps.setstring(4, "1-1-0111"); ps.setstring(5, "501"); ps.executeupdate(updatesql); 

but still same output shown .

what is:

private static final string update_item =         "update `employee_info` set emp_name=?, location=?, email=?, dob=? emp_id=?";  public void updateemployeedetails(employee employee) {      connection conn = null;     preparedstatement ps = null;      try {          conn = jdbcutility.getconnection();         ps = conn.preparestatement(update_item);         ps.setstring(1, employee.getemp_name()); /*all attributes of employee object of type string */         ps.setstring(2, employee.getlocation());         ps.setstring(3, employee.getemail());         ps.setstring(4, employee.getdob());         ps.setstring(5, employee.getemp_id());         ps.executeupdate();      } catch (sqlexception e) {         system.out.println(e.geterrorcode());         e.printstacktrace();     } } 

but can double check returns employee.getemp_name()?


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -