【环境问题】基础Web环境搭建问题记录2——Failed to obtain JDBC Connection;

环境:
MacBook Pro 15
jdk8
IntelliJ IDEA
基础Web框架:Spring+SpringMVC+MyBatis+MySQL+Maven

问题:

Error querying database. Cause:
org.springframework.jdbc.CannotGetJdbcConnectionException:
Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out….
这里写图片描述

解决:
jdbc.properties文件配置错了,url多配置了个斜杠/,maff!!!

TIPS:
以上问题可能有一下原因造成:

①驱动配置有误:driver=com.mysql.jdbc.Driver
②数据库连接地址有误:url=jdbc:mysql://localhost:3306/database_name
③数据库密码或帐号有误
④数据库未启动或无权访问
⑤项目未引入对应的数据库驱动jar包:mysql-connector-java-5.1.6-bin.jar
⑥mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on . to ‘root’@’%’ identified by ‘root’ with grant option;
flush privileges;

参考:

数据库连接池的几个常见bug:

猜你喜欢

转载自blog.csdn.net/guodonggang/article/details/81478012
今日推荐