1. 程式人生 > >關於java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)問題解決

關於java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)問題解決

今天使用mybatis框架進行資料庫訪問時,出現:

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 config/mapper/user.xml
### The error may involve test.findUserById
### The error occurred while executing a query
### Cause: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

。。。

的錯誤,檢視網上的解決方案,大概分成兩種:一種是資料庫訪問出現了問題;一種是編碼的問題。

經過檢驗,我的資料庫訪問是沒有問題的,仔細檢視程式碼,發現配置檔案中資料庫的密碼寫錯了!以此謹記自己的錯誤。