java web项目关闭时内存泄漏
最近自己写的一个web项目,但是关闭tomcat的时候都会报警告,说是线程没有停止,内存泄漏
警告: The web application [ImageUpload] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
四月 17, 2017 8:10:25 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [ImageUpload] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:43)
四月 17, 2017 8:10:25 下午 org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
警告: The web application [ImageUpload] appears to have started a thread named [Resource Destroyer in BasicResourcePool.close()] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.io.BufferedOutputStream.write(BufferedOutputStream.java:117)
java.io.FilterOutputStream.write(FilterOutputStream.java:97)
com.mysql.cj.mysqla.io.SimplePacketSender.send(SimplePacketSender.java:46)
com.mysql.cj.mysqla.io.TimeTrackingPacketSender.send(TimeTrackingPacketSender.java:43)
com.mysql.cj.mysqla.io.MysqlaProtocol.send(MysqlaProtocol.java:552)
com.mysql.cj.mysqla.io.MysqlaProtocol.quit(MysqlaProtocol.java:1294)
com.mysql.cj.mysqla.MysqlaSession.quit(MysqlaSession.java:224)
com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:3239)
com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:1113)
com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:642)
com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:255)
com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:622)
com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1076)
com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1101)
com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1062)
com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:44)
com.mchange.v2.resourcepool.BasicResourcePool$5.run(BasicResourcePool.java:1316)
网上给出的方法是注册listener然后写一个ServletContextListener来在程序关闭的时候关闭相应的线程
想问一下有没有其他方法,担心是配置出了问题