今天学习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数据库中的表名和字段名不可以使用单引号,要使用` (键盘左上角)

Logo

更多推荐