具体异常如下:
JavaEE
(1)
收藏
我要回答
可以做个监听器:
@WebListener public class ContextFinalizer implements ServletContextListener { private static final Logger logger = LoggerFactory.getLogger(ContextFinalizer.class); public void contextInitialized(ServletContextEvent sce) { } public void contextDestroyed(ServletContextEvent sce) { Enumeration<Driver> drivers = DriverManager.getDrivers(); Driver d = null; while (drivers.hasMoreElements()) { try { d = drivers.nextElement(); DriverManager.deregisterDriver(d); logger.warn(String.format("Driver %s deregistered", d)); } catch (SQLException ex) { logger.warn(String.format("Error deregistering driver %s", d), ex); } } AbandonedConnectionCleanupThread.uncheckedShutdown(); } }
可以做个监听器: