1.报错:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error updating 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.
### The error may exist in file [C:\Elichika\IDEA-workspace\seckill\target\classes\mapper\SecKillDao.xml]
### The error may involve org.seckill.dao.SeckillDao.reduceNumber
### The error occurred while executing an update
### 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.
2.遇到过这个情况两次
①使用的MySQL数据库8.X版本,官方更新了文档,properties文件写法发生了改变
②spring-dao.xml文件中配置数据库连接池时多打了一个中括号,编译器没有报错,IDEA自动将properties文件中的值替换过来,遮挡住了源代码,一直没有发现
3.解决办法
正确的properties文件写法
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/数据库名?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull
jdbc.username=
jdbc.password=