WD1X.COM - 问答一下,轻松解决,电脑应用解决专家
主板显卡CPU内存显示器
硬盘维修显卡维修显示器维修
注册表系统命令DOS命令Win8
存储光存储鼠标键盘
内存维修打印机维修
WinXPWin7Win11Linux
硬件综合机箱电源散热器手机数码
主板维修CPU维修键盘鼠标维修
Word教程Excel教程PowerPointWPS
网络工具系统工具图像工具
数据库javascript服务器
PHP教程CSS教程XML教程

Caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException错误解决

更新时间:2021-03-16 10:31 作者:水巷石子点击:
报错信息如下:
 
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";
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
你可能感兴趣的内容