問題描述
使用IDEA用maven管理項目,使用spring+jdbc連接數據庫,最后編寫測試類運行后
出現如下錯誤
問題重現
Could not get JDBC Connection nested exception is java.sql.SQLException...
Connections could not be acquired from the underlying database!

問題分析
根據網絡上的解答教程,可知此問題的原因是
mysql數據庫驅動和mysql數據庫版本不一致,具體配置是
mysql為V 8.0.21,mysql-connector-drive是V 5.1.6
問題解決
使用maven 修改配置文件,將mysql-connector版本改為8.0.21即可
⚠️ 注: 在新版的驅動中
新增了cj包

直接使用jdbc下的Driver也行
