Java Tomcat热部署,JDBC驱动注销失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23545305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 23:46:12  来源:igfitidea点击:

Tomcat hot deployment, JDBC driver failed to unregister

javatomcatjdbc

提问by Alex

I have the exception after updating a file and hot deployment it to Tomcatserver.
Does anybody know what is wrong?

更新文件并将其热部署到Tomcat服务器后出现异常。
有人知道出了什么问题吗?

SEVERE: The web application [/app] registered the JDBC driver [org.postgresql.Driver]  
but failed to unregister it when the web application was stopped.
To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

Env.

环境

     - Tomcat 6 or 7 (the same error)
     - Eclipse Helios
     - JDK 1.7.0_55 with "Default VM parameters":
       -Xms256M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M

回答by lamar

Find the correct JDBC Driver jar and download to the WEB-INF lib folder.

找到正确的 JDBC Driver jar 并下载到 WEB-INF lib 文件夹。

回答by rkosegi

Meaning of message is that Tomcat already took an action to correct leak caused by not unregistering JDBC driver.

消息的意思是 Tomcat 已经采取了措施来纠正由于未注销 JDBC 驱动程序而导致的泄漏。

If you're unsure how to unregister JDBC driver in ServletContextListener, you can try something like this:

如果您不确定如何在 ServletContextListener 中取消注册 JDBC 驱动程序,您可以尝试以下操作:

Enumeration<java .sql.Driver> drivers = java.sql.DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
    java.sql.Driver driver = drivers.nextElement();
    try {
       java.sql.DriverManager.deregisterDriver(driver);
    } catch (Exception e) {
        //log exception or ignore
    }
}