DBCP

官网:http://commons.apache.org/proper/commons-dbcp/

问题

每次请求Http接口Mysql都会新建一个Connection,很明显没有从连接池中取Connection,反而池里的连接占着不用浪费了空间,直到Connection的数量超过maxActive报错,然后再重启,永远发现不了问题。。。

SELECT id, db, user, host, command, time, state, info 
from information_schema.PROCESSLIST
WHERE 1=1 
-- and command != 'Sleep'
 AND HOST LIKE '%localhost%'
order BY id 

DBCP连接回收问题

使用完BasicDataSource连接池获取的连接后,要在finally中调用close()方法,close()方法被重写后作用变成了手动将连接返还给连接池。DBCP连接回收问题

 

除了手动调用立刻回收到连接池中的方法外,还有配置指定时间回收到连接池,待研究。

 

相关文章:

  • 2021-10-18
  • 2021-08-26
  • 2021-09-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
猜你喜欢
  • 2021-07-19
  • 2022-02-27
  • 2021-10-20
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案