如何防止Tomcat6在WEB-INF/lib中预加载JDBC驱动程序? [英] How can I prevent Tomcat6 from pre-loading JDBC Drivers in WEB-INF/lib?

查看:144
本文介绍了如何防止Tomcat6在WEB-INF/lib中预加载JDBC驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Web应用程序的WEB-INF/lib中有许多JDBC Driver jar文件-例如oracle和SQL-Server.在Tomcat7中,如果Web应用程序仅使用oracle,则不会注册SQL-Server驱动程序,但是在Tomcat6中,它会注册(我可以从ServletContextListener中的contextDestroyed()中看到此信息,该注册器会注销由该类加载器加载的驱动程序)

I have a number of JDBC Driver jar files in my webapp's WEB-INF/lib - e.g. oracle and SQL-Server. In Tomcat7, if the webapp only uses oracle, the SQL-Server driver doesn't get registered, but in Tomcat6 it does (I can see this from my contextDestroyed() in a ServletContextListener, which de-registers Drivers loaded by this classloader).

Tomcat6是否以某种方式从WEB-INF/lib中的jars预加载了类?如果是这样,可以禁用此功能吗?

Is Tomcat6 somehow pre-loading classes from jars in WEB-INF/lib? If so, can this be disabled?

(我知道在共享库中这些jar会更好,但这是另一个问题...)

(I know these jars would be better in the shared lib, but this is another issue...)

推荐答案

永远不要将驱动程序放在webapp类路径中.始终将其放入服务器的类路径中.

Never ever put drivers in the webapp class path. Put it always into the server's classpath.

context.xml中声明一个DataSource,然后使用.

Declare a DataSource then in your context.xml and then free the resources with this.

这篇关于如何防止Tomcat6在WEB-INF/lib中预加载JDBC驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆