org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: Cannot open connection; uncategorized SQLException for SQL [???]; SQL state [null]; error code [0]; Connections could not be acquired from the underlying database!; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
以上问题可能有一下原因造成:
1,驱动配置有误:driver=com.mysql.jdbc.Driver //oracle则写其对应驱动
2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?haracterEncoding=utf8 //oracle则为:url=jdbc:oracle:thin:@localhost:1521:test
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;
有3种可能:
1.数据库没有启动,可以打开数据库客户端,如果客户端能访问,比如SQLSERVER的查询分析器或者Mysql的SQLyog,则代表数据库正常,排除此可能。
2.数据库连接url没写正确,
ip地址,数据库名【数据库是否存在?还是名字写错】,如果你没有使用hibernate还要检查用户名、密码是否正确。
3.数据库连接驱动包不正确、不匹配,或者甚至没有。
检查lib目录下是否有对应数据库的jar包。