Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed异常

一、问题描述

异常信息:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!

二、原因排查

通过上网查证,主要是可能有三类问题导致这个错误
第一类:数据库的权限问题
数据库未启动或无权访问
mysql root没有远程访问的权限,需要增加权限
第二类:配置信息错误(8.0以上版本没有添加时区)

驱动配置有误:driver=com.mysql.cj.jdbc.Driver
数据库连接地址有误:url=jdbc:mysql://localhost:3306/test(此处修改为自己的)?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT&nullCatalogMeansCurrent = true

密码或帐号有误

但是如果是账号密码错误会显示以下错误信息:Access denied for user ‘root’@‘localhost’ (using password: YES))

第三类:MySQL驱动版本问题
在没有低级失误的情况下,大概率是这里导致的

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>