错误日志(.BadSqlGrammarException:错误的sql参数异常,明明参数和表中数据都对应上了,其实很简单的错误,秒解决)
短信预约 信息系统项目管理师 报名、考试、查分时间动态提醒
nested exception is org.springframework.jdbc.BadSqlGrammarException
错误的sql参数异常,明明参数和表中数据都对应上了,其实很简单的错误,秒解决
{
"timestamp": "2019-12-17T02:09:41.445+0000",
"status": 500,
"error": "Internal Server Error",
"message": "
### Error updating database. 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 "desc,class_id ) VALUES( "王权富贵",1,18,2000.0,"浩浩星河谁为主",1 )" at line 1
### The error may involve com.czxy.mapper.StudentMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO tb_student ( sname,gender,age,salary,desc,class_id ) 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 "desc,class_id ) VALUES( "王权富贵",1,18,2000.0,"浩浩星河谁为主",1 )" 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 "desc,class_id ) VALUES( "王权富贵",1,18,2000.0,"浩浩星河谁为主",1 )" at line 1",
"path": "/student"
}
很简单的一个添加,报的的错是说我的sql语法有问题,检查了类里的信息,"desc,class_id"和表里的都对应上了,没问题,弄了好长时间,还是没弄出来,找班里的大神秒解决了,其实原因很简单"desc"是order里的降序排序(关键字),添加数据sql当然报语法错误
解决方案:
在@Column对应的表中数据上加上mysql的转义字符``即可
还是思维固化,想的不够灵活,没想过是字段名的问题
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341