第一种情况

出现错误

### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 5, maxActive 5

                finally {
                    rs.close();
                    stmt.close();
                    conn.close();  
                }

没有关闭连接

这里baseConn是通过druid datasource获取的一个PgSQL 底层连接, 上面代码执行完后,finally中调用baseConn.close()关闭了这个连接,

 

第二种情况

出现错误

com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 60000, active 0, maxActive 20, creating 1

数据设置的是懒加载方式,获取连接,还需要创建连接,获取连接超时

private static DataSource pool=null;

public static Pool getPool(){

    if(pool==null){

        init();

    }

}

设置成立即加载方式

 

第三种情况

出现错误

socket read time out

更新表的时候有错误

druid的连接池设置超时时间设置长一点

pool.setMaxWait(2000L);  ->   pool.setMaxWait(10000L);

 

 

 

 

转载地址:

https://www.cnblogs.com/spec-dog/p/6226212.html  (第一种情况)

 

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐