You have an error in your SQL syntax; for the right syntax to use near 'xxx'

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pulong0748/article/details/81746039

Error querying 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 ‘order by
解决思路:
1:先把mybatis 生成的SQL到数据库中去运行一下。
2:仔细查看你的SQL语句中是否存在mysql关键字
我的问题:
这里写图片描述
可以从这张图上看出来提示说设置参数出现了问题?????那么问题在哪里??对比下面两张图你就懂了
这里写图片描述
这里写图片描述
是我sql写错了 应该是tcpb.state=#{state},我写成了tcpb.state={#state},所以会报设置参数错误。正常的话打印出来的SQL语句是tcpb.state=?

关键字导致的错误:
Caused by: 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 ‘explain = ‘不通过填写原因’,
很快我就定位到explain 那里,然后百度一下explain是不是关键字,果然是。
错误写法
正确写法
一定要注意这个引号是键盘最左上角的那个。

猜你喜欢

转载自blog.csdn.net/pulong0748/article/details/81746039