JDBC驱动程序是否应包含在WAR中? [英] Should JDBC drivers be included in a WAR?

查看:94
本文介绍了JDBC驱动程序是否应包含在WAR中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个正在开发的商业软件产品.它支持Oracle,MySQL和SQL * Server后端(我们也使用H2进行测试).我们使用特定版本的JDBC驱动程序针对那些不同的数据库进行集成测试. Maven可以很好地处理所有这一切.

We have a commercial software product under development. It supports Oracle, MySQL, and SQL*Server backends (we also use H2 for testing). We do our integration testing against those different database using JDBC drivers of a specific version. Maven handles all this beautifully.

在将应用程序打包为WAR时,是否可以包括JDBC驱动程序?什么是标准做法?

When packaging the application as a WAR, is it ok if we include the JDBC drivers? What is the standard practice?

由于我们不知道可以提前使用哪个数据库,因此我们必须将它们全部包括在内.目标servlet容器是Tomcat和Jetty,但是一些客户也希望在WebSphere和JBoss中运行.

Since we don't know which database could be used ahead of time, we'd have to include them all. The targeted servlet containers are Tomcat and Jetty, but some customers will also want to run within WebSphere and JBoss.

那么servlet包含并且应用程序服务器带有它们自己的JDBC驱动程序吗?我们会发生冲突吗?另一个问题是,我们已经使用一个版本的驱动程序进行了开发和测试,如果客户使用另一版本的驱动程序,我们可能会遇到问题.

So the servlet contains and application servers come with their own JDBC drivers? Will ours conflict? Another concern is that we have developed and tested with one version of the driver and if a customer uses another version, we may have problems.

当前,我们使用Spring数据源bean,但是正在转向对数据源进行JNDI查找.

Currently we use Spring data source beans, but are in the process of moving to JNDI lookup for the datasource.

推荐答案

那么servlet包含并且应用程序服务器带有它们自己的JDBC驱动程序吗?

So the servlet contains and application servers come with their own JDBC drivers?

可以(例如WebLogic).

Some do (e.g. WebLogic).

我们会发生冲突吗?

Will ours conflict?

他们不应该.但是,不确定在应用程序级别创建独立连接池时是否会选择您的连接池(所有这些都取决于类加载器委派模式).

They shouldn't. Not sure yours will be picked when creating an standalone connection pool at the application level though (it all depends on the classloader delegation mode).

另一个问题是,我们已经使用一个版本的驱动程序进行了开发和测试,如果客户使用另一版本的驱动程序,我们可能会遇到问题.

Another concern is that we have developed and tested with one version of the driver and if a customer uses another version, we may have problems.

具有支持的版本列表.

当前,我们使用Spring数据源bean,但是正在转向对数据源进行JNDI查找.

Currently we use Spring data source beans, but are in the process of moving to JNDI lookup for the datasource.

如果这是要使用应用程序服务器提供的连接池,则必须在容器级别而不是应用程序级别安装驱动程序.这样就结束了讨论.

If by this you mean using the connection pool provided by an application server, drivers must be installed at the container level, not at the application level. And this somehow ends the discussion.

这篇关于JDBC驱动程序是否应包含在WAR中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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