异常描述:
org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is org.apache.tomcat.jdbc.pool.PoolExhaustedException:
[main] Timeout: Pool empty. Unable to fetch a connection in 30 seconds, none available[size:100; busy:100; idle:0; lastwait:30000].
坑爹的货,遇到这个问题通常需要去定位下哪里获取了数据库连接但没有释放关闭,因为自己在搭建一个数据抽取的程序,框架都是自己搭的,让我一度任务是没有接入数据源导致的,后来接入了druid数据源,但还是有问题,最后认证查看日志发现是由于用jdbctemplate获取了connect没有关闭导致。
修改如下:
jdbcTemplate.getDataSource().getConnection().close();