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是不是关键字,果然是。
一定要注意这个引号是键盘最左上角的那个。