相关推荐recommended
简单解决 Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
作者:mmseoamin日期:2023-12-21

问题描述

insert操作时莫名报错

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

简单解决 Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException,在这里插入图片描述,第1张