简单解决 Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

问题描述

insert操作时莫名报错

java">org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: ***.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 'record  ( oid,
number,
operator,
operator_describe )  VALUES  ( 28,
'AS16986482811111' at line 1
### The error may exist in ***/xxx/xxx/order/dao/OrderOperatingRecordDao.java (best guess)
### The error may involve ***.xxx.xxx.order.dao.OrderOperatingRecordDao.insert-Inline
### The error o***urred while setting parameters
### SQL: INSERT INTO order_operating record  ( oid, number, operator, operator_describe )  VALUES  ( ?, ?, ?, ? )
### Cause: ***.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 'record  ( oid,

拷贝报错信息里的SQL去数据库执行也是报错,说明是SQL语句有问题

### SQL: INSERT INTO order_operating record  ( oid, number, operator, operator_describe )  VALUES  ( ?, ?, ?, ? )

原因分析:

查找之后发现是数据库表名有问题。正确的表名应该是order_operating_record。但是目前的表名是order_operating record少了一个下划线_


解决方案:

1、将数据库表名修改正确order_operating_record
2、将@TableName()注解表名修改正确

转载请说明出处内容投诉
CSS教程_站长资源网 » 简单解决 Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买