Should JDBC drivers be included in the WAR?

We have a commercial software product that is being developed. It supports Oracle, MySQL and SQL * Server (we also use H2 for testing). We are testing integration with these different databases using specific version JDBC drivers. Maven does a great job of all this.

When packaging an application as a WAR, is it good if we enable JDBC drivers? What is the standard practice?

Since we do not know which database can be used ahead of time, we will have to include all of them. The target servlet containers are Tomcat and Jetty, but some clients will also want to run on WebSphere and JBoss.

So, does the servlet contain and the application servers have their own JDBC drivers? Will there be our conflict? Another problem is that we developed and tested with one version of the driver, and if the client uses a different version, we may have problems.

We are currently using Spring beans data source, but are in the process of moving on to looking for JNDI for the data source.

+6
java jdbc servlets
source share
3 answers

So, does the servlet contain and the application servers have their own JDBC drivers?

Some of them (for example, WebLogic).

Will there be our conflict?

They should not. Not sure if yours will be selected when creating a separate connection pool at the application level (it all depends on the loader delegation mode).

Another problem is that we developed and tested with one version of the driver, and if the client uses a different version, we may have problems.

List of supported versions.

We are currently using Spring beans data source, but are in the process of moving on to looking for JNDI for the data source.

If you intend to use the connection pool provided by the application server, the drivers should be installed at the container level and not at the application level. And this somehow ends the discussion.

+7
source share

In most applications, JDBC drivers are not sent as part of the application.

If you submit JDBC drivers, this means that you need to provide drivers for the entire database that you want to support. This adds a lot of unnecessary libraries.

Just do not add any driver or tell the user to put the corresponding JAR file in the server libraries.

+6
source share

Other than the technical advantages of including a driver in a military file, you should also check the driver license and make sure that it is distributed by a third party.

+3
source share

All Articles