14 Using JDBC Drivers with WebLogic Server

This chapter describes how to set up and use JDBC drivers with WebLogic Server.

JDBC Driver Support

WebLogic Server provides support for application data access and database dependent features. For more information, see "Database Interoperability" in What's New in Oracle WebLogic Server.

JDBC Drivers Installed with WebLogic Server

The 11g version of the Oracle Thin driver (ojdbc6.jar, ojdbc6_g.jar, and ojdbc6dms.jar for JDK 6) is installed with Oracle WebLogic Server.

Note:

WebLogic-branded DataDirect drivers are also installed with WebLogic Server. See Using WebLogic-branded DataDirect Drivers for more information.

In addition to the Oracle Thin Driver, the mySQL 5.1.x (mysql-connector-java-commercial-5.1.22-bin.jar) JDBC driver is installed with WebLogic Server.

This driver is installed in subdirectories of $ORACLE_HOME/oracle_common/modules. The manifest in weblogic.jar lists this file so that it is loaded when weblogic.jar is loaded (when the server starts). Therefore, you do not need to add this JDBC driver to your CLASSPATH. If you plan to use a third-party JDBC driver that is not installed with WebLogic Server, you must install the drivers, which includes updating your CLASSPATH with the path to the driver files, and may include updating your PATH with the path to database client files. See "Supported Configurations" in What's New in Oracle WebLogic Server.

If you plan to use a different version of any of the drivers installed with WebLogic Server, you can add the new file to the front of your CLASSPATH. See Updating JDBC Drivers.

Note:

WebLogic Server also includes a version of the Derby DBMS installed with the WebLogic Server examples in the WL_HOME\common\derby directory. Derby is an all-Java DBMS product included in the WebLogic Server distribution solely in support of demonstrating the WebLogic Server examples. For more information about Derby, see http://db.apache.org/derby.

Setting the Environment for a Third-Party JDBC Driver

If you plan to use a third-party JDBC driver that is not installed with WebLogic Server, you need to update the WebLogic Server's classpath to include the location of the JDBC driver classes. Edit the commEnv.cmd/sh script in WL_HOME/common/bin and prepend your classes as described in "Modifying the Classpath" in the Command Reference for Oracle WebLogic Server.

Updating JDBC Drivers

To update a JDBC driver:

  1. Backup the current JDBC driver jar files. Drivers installed with WebLogic Server are located in subdirectories of the $ORACLE_HOME/oracle_common/modules directory.

  2. Replace the old jar files with new/patched jar files.

  3. Determine if you need to modify your CLASSPATH:

    • If the third-party JDBC driver was installed with WebLogic Server and the replacement jar has the same name as the original driver, you do not need to modify CLASSPATH. The manifest in the weblogic.jar file includes correct references to the new jar files so the new driver is loaded when the server is started.

    • If the third-party JDBC driver was not installed with WebLogic Server or the replacement jar has a different name than the original driver, you must add the location of the jar file to the head of the CLASSPATH used when starting WebLogic Server. It must be located before any client jar files. You may need to update your PATH with the path to any database client files. See "Supported Configurations" in What's New in Oracle WebLogic Server.

Globalization Support for the Oracle 11g Thin Driver

For Globalization Support with the 11g version of the Oracle Thin driver, Oracle supplies the orai18n.jar file, which replaces nls_charset.zip. If you use character sets other than US7ASCII, WE8DEC, WE8ISO8859P1 and UTF8 with CHAR and NCHAR data in Oracle object types and collections, you must include orai18n.jar and orai18n-mapping.jar in your CLASSPATH.

The orai18n.jar and orai18n-mapping.jar are included with the WebLogic Server installation in the ORACLE_HOME\oracle_common\modules\oracle.nlsrtl_11.2.0 folder. These files are not referenced by the weblogic.jar manifest file, so you must add them to your CLASSPATH before they can be used.

Using the Oracle Thin Driver in Debug Mode

The ORACLE_HOME\oracle_common\modules\oracle.jdbc_11.2.0 folder includes the ojdbc6_g.jar (for JDK 6) file, which are the versions of the Oracle Thin driver with classes to support debugging and tracing. To use the Oracle Thin driver in debug mode, add the path to these files at the beginning of your CLASSPATH.