Reputation: 27
String sql = "INSERT INTO order " + "(customerid, pant, shirt, date) "
+ "VALUES ('" + jTextField1.getText() + "','" + jTextField2.getText()
+ "','" + jTextField3.getText() + "','" + jTextField4.getText() + "')";
When tried this, I got the following error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near
'order (customerid, pant, shirt, date) VALUES ('10','2','3','26')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method).
Upvotes: 0
Views: 234
Reputation: 204746
You need to escape reserved words like order
with backticks
INSERT INTO `order` (customerid, ...
Besides that I recommend using Prepared Statements.
Upvotes: 4
Reputation: 18600
Table name "order" is reserve word so please change table name and try it.
Upvotes: 0