mybatis-mybatis中使用mysql数据库关键字问题
问题描述在进行业务测试时,发现总是报sql异常,查看xml中的sql语句时也没有发现问题。在百度上进行查询时才发现可能是关键字导致的问题。突然醒悟,然后到数据库查看,果然使用了关键字“order”作为字段。Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;check the manua...
·
问题描述
在进行业务测试时,发现总是报sql异常,查看xml中的sql语句时也没有发现问题。在百度上进行查询时才发现可能是关键字导致的问题。突然醒悟,然后到数据库查看,果然使用了关键字“order”作为字段。
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, product, price,
quantity, type, user,
send_time, add_time, upd' at line 1
### The error may exist in file [F:\ideaworkspace\prospect-hill-mes\target\classes\mapper\MesOrderManagerDetailMapper.xml]
### The error may involve com.prospect.mes.mbg.mapper.MesOrderManagerDetailMapper.insert-Inline
### The error occurred while setting parameters
### SQL: insert into mes_order_manager_detail (order, product, price, quantity, type, user, send_time, add_time, update_time, remarks, status, deleted ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### 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, product, price,
quantity, type, user,
send_time, add_time, upd' at line 1
; 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, product, price,
quantity, type, user,
send_time, add_time, upd' at line 1] with root cause
解决方案
1.修改数据库中的关键字字段
2.修改java项目中的对应数据库映射对象类的字段
3.重新编译运行测试
参考文章
mysql中应注意的关键字有哪些?

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)