摘要:该文适用于黑马Javaweb项目的配置,用到mybatis配置数据库连接,用到mapper接口和其xml文件连接数据库
数据库连接问题,显示密码错误,无法连接数据库
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
### The error may exist in com/itheima/mapper/BrandMapper.xml
### The error may involve com.itheima.mapper.BrandMapper.selectByPageAndCondition
### The error occurred while executing a query
### Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
连接数据库的密码错误
### Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
mybatis-config.xml的配置错误,1处值与你自己的配置不一样
进入
mybatis-config.xml
查看代码把username和password的value值改成你自己设置的值就可以解决了
注:
1.driver属性中可能有问题 (影响不大,但建议修改)
com.mysql.jdbc.Driver
是 mysql-connector-java 5版本以下的,com.mysql.cj.jdbc.Driver
是 mysql-connector-java 6版本以上的。
2.url的值为 : jdbc:mysql:///数据库架构名称?useSSL=false
我的数据库是这个样子的:要用db1下的表url配置就是jdbc:mysql:///db1?useSSL=false