Share a solution that uses c3p0,tomcat to escape memory

Source: Internet
Author: User
Tags tomcat server
Http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered
/**   *  @author  aray chou   *         email:  aray (dot) Chou (dot) CN (at) gmail (dot) com   *          replace  "(dot)"  with  "."  and replace  "(at)"  with  "@"   * * import  javax.servlet.ServletContextEvent; import  Javax.servlet.ServletContextListener; import  Javax.servlet.annotation.WebListener; import  Javax.sql.DataSource;   import  com.mchange.v2.c3p0.DataSources;  /**   *&NBSP;C3P0 Connection pool When the context is shut down (Tomcat server or reload context is turned off), resources are not reclaimed, resulting in memory leaks. Tomcat reported the following error:   * <br />severe: the web application [/xxx] appears  to have started a thread named [ com.mchange.v2.async.threadpoolasynchronousrunner$poolthread-#1] but has failed to  Stop it. this is very likely&nbSp;to create a memory leak.   *    *  This class releases the C3P0 connection pool at the time the context is closed to resolve this type of save and leak problem.   *    *  In addition, the JDBC driver package (for example, Ojdbc6.jar) is placed under $tomcat_home/lib and not in web-inf/lib to address the problem of the JDBC driver causing memory leaks. At this time Tomcat reported the following error:   * severe: a web application registered the jbdc  Driver [oracle.jdbc.oracledriver] but failed to unregister it when the  web application was stopped. to prevent a memory leak, the  jdbc driver has been forcibly unregistered.   * @WebListener () public  class  dbcloser  implements  servletcontextlistener { 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.