報錯資訊如下:
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
The error may exist in com/lbl/dao/IPersonDao.xml
The error may involve com.lbl.dao.IPersonDao.findAll
The error occurred while executing a query
Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Client does not support authentication protocol requested by server; consider upgrading MySQL client
The error may exist in com/lbl/dao/IPersonDao.xml
The error may involve com.lbl.dao.IPersonDao.findAll
The error occurred while executing a query
MySQL版本和驅動包不兼容的問題
于是我查看了自己的mysql版本

再看了看自己pom.xml檔案的mysql驅動版本

再查看自己連接資料庫時,連接的是哪一個版本的資料庫

這就找到了報錯的原因了,
原因:
mysql驅動是5.0+版本的,而連接的資料庫版本是8.0+版本的,所以連接不上,
解決辦法:
1.改連接資料庫與mysql驅動版本一致的5.0+版本
2.改mysql驅動為8.0+版本
這里要注意,如果將mysql驅動改為8.0+版本,則還要改驅動的類名,加cj欄位
把驅動的類名改為:
driver="com.mysql.cj.jdbc.Driver";
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/179159.html
標籤:其他
上一篇:MySQL面試互問
