Zombie Connections to MySQL using c3p0 with tomcat

感情迁移 提交于 2019-12-03 21:06:23
Mark Thomas

There are a couple of possibilities.

The most likely is that you have placed this Resource element in $CATALINA_BASE/conf/context.xml That file provides the default context.xml for every web application. Therefore, if you have six web applications you will have six connection pools. Since the minimum poll size is 200, there will be a minimum of 200*6=1200 connections opened to the database.

The other possibility is that the web application has been reloaded. You should get a new connection pool and the old one will be GC'd. However, if you have a memory leak on reload (very easy to do without realising) it may keep the connection pool, along with its open connections, in memory increasing your total connections.

To put the definitions in server.xml:

<Server>
  <GlobalNamingResources>
     <Resource name="jdbc/xxxx">...</Resource>
  </GlobalNamingResources>
</Server>

and this in context.xml:

  <ResourceLink name="jdbc/xxxx"
      global="jdbc/xxxx"
      type="com.mchange.v2.c3p0.ComboPooledDataSource" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!