A ResourcePool could not acquire a resource from its primary factory or source异常解决

A ResourcePool could not acquire a resource from its primary factory or source异常解决

一. 异常问题

我在给别人做项目的时候,我自己本地连接的数据库是5.7,用的mysql-connector-java的驱动包是5.x版本的,然后对方的环境中mysql是8.0.

结果在启动程序后,在用户登录,第一次连接数据库时,就产生了如下异常信息: 

......
 A ResourcePool could not acquire a resource from its primary factory or source
 ......

二. 原因分析

经过各种查询,可能的原因如下:

  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;

三. 解决办法

以上检查完了之后,发现没有可以解决我的问题的,后来发现,是因为数据库版本问题。

我的是mysql5.7,对方的是mysql8.0,然后更换了数据库版本就好了。

 

 

你可能感兴趣的:(异常解决)