c3p0无法连接的相关处理,问题:Connections could not be acquired from the underlying database!

我遇到的问题:

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 versionJDBC versionMySQL Server versionJRE RequiredDK Required for CompilationStatus
8.04.2 15.6, 5.7, 8.0JRE 8 or higherJDK 8.0 or higher3General availability. Recommended version
5.13.0, 4.0, 4.1, 4.25.62, 5.72, 8.02JRE 5 or higher2JDK 5.0 AND JDK 8.0 or higher3General 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.csdn.net/hchhan/article/details/81106992
  • https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-versions.html
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值