I have encountered this error for a two of times.
1 The name of my field coincides with the keyword of the database.
Desc in is the default descending order of the meaning.
2 The second occurrence of the exception is a bug I encountered during the refactoring code phase. But I can't understand it for the time being, although it solves the mistake.
The code for the delete operation is as follows:
Public void deleteproduct (Long id) { = "DELETE from t_product WHERE id=?" ; JDBCTEMPLATE.TEMPLATEDML (Sql,id); }
Or the following wording: All is correct.
Public void deleteproduct (Long id) { = "DELETE from t_product WHERE id=" +ID; JDBCTEMPLATE.TEMPLATEDML (SQL); }
But there is a problem when you query a result:
Public Product Getproductbyid (Long ID) { sql= "SELECT * from t_product WHERE id=?" ; List<Product> list = jdbctemplate.templatedql (sql,id); return list.size () ==1?list.get (0):null; }
After the change can be again;
Public Product Getproductbyid (Long ID) { sql= "SELECT * from t_product WHERE id=" +ID; List<Product> list = jdbctemplate.templatedql (sql); return list.size () ==1?list.get (0):null; }
Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; Che