java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corres
原创
©著作权归作者所有:来自51CTO博客作者HezhezhiyuLe的原创作品,请联系作者获取转载授权,否则将追究法律责任
前言
使用通用mapper插入对象报错,检查代码和映射类均无问题
; bad SQL grammar []; nested exception is 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 ( state,c_time,o_id,start_adress,end_adress,proposer,relevant_user,remark' at line 1] with root cause
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 ( state,c_time,o_id,start_adress,end_adress,proposer,relevant_user,remark' at line 1
排查
复制出SQL进入SQLyog测试,发现失败,这时候想到是关键字问题,使用引号括住关键字
SELECT * FROM `order`;
INSERT INTO `order` ( state,c_time,o_id,start_adress,end_adress,proposer,relevant_user,remarks,start_time,end_time,other ) VALUES( 1,'2','3','4','5','6','7','8','9','10','11' )
原因1
表名是数据库关键字
解决:1 更改数据库表名 2使用注解@Table(name = "
order")
之后发现新的继续录入