大家好,我是考100分的小小码 ,祝大家学习进步,加薪顺利呀。今天说一说错误日志(.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"
}
代码100分
很简单的一个添加,报的的错是说我的sql语法有问题,检查了类里的信息,”desc,class_id”和表里的都对应上了,没问题,弄了好长时间,还是没弄出来,找班里的大神秒解决了,其实原因很简单”desc”是order里的降序排序(关键字),添加数据sql当然报语法错误
解决方案:
在@Column对应的表中数据上加上mysql的转义字符“即可
还是思维固化,想的不够灵活,没想过是字段名的问题
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/10435.html