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";