When I tried to execute the following java code I face the issue
java.sql.SQLSyntaxErrorException: 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 SET ord_name = 'OD1320210903122013', shipcost = '0.0', price='799.0', supp' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
Below the code :
String order = "INSERT INTO order SET ord_name = ?, shipcost = ?, price=?, supplierid=?, userid=?, suppliername=?, shippingdate=?, shipaddress=?, timestmp=?";
PreparedStatement ord_create = con.prepareStatement(order);
ord_create.setString(1,name);
ord_create.setString(2,String.valueOf(shippingCost));
ord_create.setString(3, String.valueOf(price));
ord_create.setString(4,String.valueOf(supplierid));
ord_create.setString(5,usr);
ord_create.setString(6,suppl_name);
ord_create.setString(7,shippingDate);
ord_create.setString(8,address);
ord_create.setString(9,timestamp);
int result = ord_create.executeUpdate();
The same statement compiled (took from debugger ) works perfectly if executed directly on MySQL Workbench
Can you help me?