java - an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax -


java.sql.sqlexception: syntax error or access violation, message server:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near ''list' (fname1,lname1,email1,email,'dob1',str,city,state,zip,order,qua,rate,comm' @ line 1"

string k="insert `list` (fname1,lname1,email1,email,'dob1',str,city,state,zip,order,qua,rate,comment,amt) values ('"+fname1+"','"+lname1+"','"+email1+"','"+email+"','"+dob1+"','"+str+"','"+city+"','"+state+"',"+zip+",'"+ord+"',"+qua+","+rating+",'"+comment+"',"+amt+")"; 

here table desc

the error message point 2 single quotes on string, check if double quote not writen 2 single quotes.

but, solve efficiently, recomended use peparedstatement in order avoid sql injection, , escape of unexpected string, @elliott pointed.

here example:

string k="insert list (fname1,lname1,email1,email,dob1,str,city,state,zip,order,qua,rate,comment,amt) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; preparedstatement ps = conn.preparestatement(k); ps.setstring(1, fname1); ps.setstring(2, lname1); ... ps.execute(); ps.close(); conn.close(); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -