spring | 踩坑 | Could not get JDBC Connectionl nested exception is java.sql.SQLException...

问题描述

使用IDEA用maven管理项目,使用spring+jdbc连接数据库,最后编写测试类运行后
出现如下错误

问题重现

Could not get JDBC Connection nested exception is java.sql.SQLException...

Connections could not be acquired from the underlying database!

image

问题分析

根据网络上的解答教程,可知此问题的原因是
mysql数据库驱动和mysql数据库版本不一致,具体配置是
mysql为V 8.0.21,mysql-connector-drive是V 5.1.6

问题解决

使用maven 修改配置文件,将mysql-connector版本改为8.0.21即可


⚠️ 注: 在新版的驱动中
新增了cj

image
直接使用jdbc下的Driver也行

参考

posted @ 2021-05-28 22:51  茶哩哩  阅读(2844)  评论(0编辑  收藏  举报