今天学习Mybatis时,碰到com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException,详细错误如下
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 ''user' where id = 1' at line 1
### The error may exist in com/cs/mybatis/model/User.xml
### The error may involve com.cs.mybatis.models.UserMapper.selectUserByID-Inline
### The error occurred while setting parameters
### SQL: select * from 'user' where id = ?原来是mysql数据库中的表名和字段名不可以使用单引号,要使用` (键盘左上角)
本文记录了在使用Mybatis过程中遇到的MySQLSyntaxErrorException错误,并详细解释了该错误的原因及解决方法。主要是由于在SQL语句中对表名和字段名误用了单引号,正确的做法应该是不加任何引号。

3859

被折叠的 条评论
为什么被折叠?



