我遇到的问题:
java.sql.SQLException: Connections could not be acquired from the underlying database!
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

处理结果
我的是因为mysql的版本和jdbc的jar包对应版本不同,每个版本的mysql有相对应的驱动jar包
特附上相关的对应关系
Table 2.1 Summary of Connector/J Versions
| Connector/J version | JDBC version | MySQL Server version | JRE Required | DK Required for Compilation | Status |
|---|---|---|---|---|---|
| 8.0 | 4.2 1 | 5.6, 5.7, 8.0 | JRE 8 or higher | JDK 8.0 or higher3 | General availability. Recommended version |
| 5.1 | 3.0, 4.0, 4.1, 4.2 | 5.62, 5.72, 8.02 | JRE 5 or higher2 | JDK 5.0 AND JDK 8.0 or higher3 | General availability |

其他原因:
1,驱动配置有误:driver=com.mysql.jdbc.Driver
2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8
3,密码或帐号有误:username=root
password=root
4,数据库未启动或无权访问
5,项目未引入对应的驱动jar包mysql-connector-java-5.1.6-bin.jar
6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
参考文章:
- https://www.iteye.com/blog/jyao-1915561
- https://blog.youkuaiyun.com/hchhan/article/details/81106992
- https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-versions.html
本文详细解析了java.sql.SQLException: Connection could not be acquired from the underlying database异常的原因及解决方案,涉及MySQL版本与JDBC驱动匹配、配置错误、权限设置等关键点,提供具体操作步骤与参考资料。
1539

被折叠的 条评论
为什么被折叠?



