org.springframework.transaction.CannotCreateTransactionException: could not open Hibernate Session.............................. Caused by: 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......................
解决方案(目前我遇到的是以下几种):
1.寻找支持重连的连接池。
在sessionFactory里配置:
true2,驱动配置有误,改正确 3,数据库连接地址有误,改之: 4,密码或帐号有误,改之 5,数据库未启动或无权访问,改之 6,项目未引入对应的驱动jar包,改之 7,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下: 进入mysql数据库:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option; flush privileges;8 是jar包冲突(例如某些项目中的class12.jar 与ojdbc.jar,坑了我好久)
Ctrl+shift+t,看看你的项目依赖里面有几个包含oracle.sql.converter.CharacterConverters这个类的jar,去掉重复的,
9 注意配置文件中, 多余的空格