解决java.sql.SQLException: Access denied for user 'dzt'@'localhost' (using password: YES)

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
# Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: 
Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: 
Access denied
for user 'dzt'@'localhost' (using password: YES) 1 The error may exist in com/dkc/mapper/UserMapper.xml 2 The error may involve com.dkc.mapper.UserMapper.selectUserByUserName 3 The error occurred while executing a query 4 Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException:
Access denied
for user 'dzt'@'localhost' (using password: YES)

根据错误提示,大概有这四部分需要检查,

1.检查对应的xml内容是否写对,主要图中三个箭头标记的地方。

2.检查第二部分就是mapper接口中对应的方法,一般这个不会出错,出错原因就是第一个原因

3.检查第三部分就是在执行过程中出现问题,检查对应的CRUD语句

4.检查数据库的账号和密码是否正确,如果已经确保自己的 账户和密码正确,那么可以在yml或者porperties文件中账户和密码加上双引号(说明:具体原因也不知道,自己创建了一个新项目,根据原来的配置文件可以访问,但是在原来项目上配置文件账户和密码必须加双引号)

 

posted @ 2020-12-24 16:52  码到成功hy  阅读(1721)  评论(0编辑  收藏  举报
获取

hahah

name age option