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.
When packaging the application as a WAR, is it ok if we include the JDBC drivers? What is the standard practice?
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.
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.
Currently we use Spring data source beans, but are in the process of moving to JNDI lookup for the datasource.
JDBC is the Java Database Connectivity standard and it provides a mechanism for Java programs to connect to databases.To access databases using JDBC, you must use a JDBC driver.
History and implementationSun Microsystems released JDBC as part of Java Development Kit (JDK) 1.1 on February 19, 1997. Since then it has been part of the Java Platform, Standard Edition (Java SE). The JDBC classes are contained in the Java package java.
Type-1 driver or JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. Type-1 driver is also called Universal driver because it can be used to connect to any of the databases.
Type 4 drivers are the most common and are designed for a particular vendor's database. In contrast, Type 3 is a single JDBC driver used to access a middleware server, which, in turn, makes the relevant calls to the database. A good example of Type 3 JDBC driver is the DataDirect SequeLink JDBC driver.
So the servlet contains and application servers come with their own JDBC drivers?
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.
Have a list of supported versions.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With