org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'zhangsan' in 'where clause'
### The error may exist in cn/jeas/mapper/UserMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select* from tb_user where user_name = zhangsan and password = '123456'
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'zhangsan' in 'where clause'
...
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'zhangsan' in 'where clause'
### The error may exist in cn/jeas/mapper/UserMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select* from tb_user where user_name = zhangsan and password = '123456'
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'zhangsan' in 'where clause'
...
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'zhangsan' in 'where clause'
...
出现这种错误的原因基本上输入你${}中参数拼接错误,在mybatis中:
1) #是占位符,会对SQL进行预编译,相当于?; $是做SQL拼接,有SQL注入的隐患
2) #不需要关注数据类型,Mybatis自动实现类型转换。 $必须自己判断数据类型
在mybatis的settings中,不允许有空的设置出现,必须要有对应的name和value