12 Using JDBC Drivers with WebLogic Server

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

This chapter includes the following sections:

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_g.jar for JDK 6) is installed with Oracle WebLogic Server.


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.0.x (mysql-connector-java-commercial-5.0.x-bin.jar) JDBC driver is installed with WebLogic Server.

This driver is installed in the WL_HOME\server\lib folder (where WL_HOME is the folder where WebLogic Server is installed) with weblogic.jar. 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 different version of any of the drivers installed with WebLogic Server, see Adding or Updating JDBC Drivers.

Copies of the MySQL and Oracle Thin drivers installed with WebLogic Server and other supporting files are installed in WL_HOME\server\ext\jdbc\. There is a subdirectory in this folder for each DBMS. If you need to revert to the version of the driver installed with WebLogic Server, you can copy the file from WL_HOME\server\ext\jdbc\DBMS to WL_HOME\server\lib.


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.

Using Third-Party JDBC Drivers

If you plan to use a third-party JDBC driver that is not installed with WebLogic Server, you must install the driver files by updating your CLASSPATH with the path to the driver files. See Adding or Updating JDBC Drivers.

For information on supported JDBC drivers, see "Supported Configurations" and "Database Interoperability" in What's New in Oracle WebLogic Server.

Adding or Updating JDBC Drivers

To add a new or update an existing JDBC driver:

  1. If you are updating existing JDBC drivers, make backup copies of the corresponding JAR files. Drivers installed with WebLogic Server are located in the WL_HOME\server\lib directory.

  2. In the appropriate location, add the new driver JAR. If the driver has a different name, add the new driver JAR and remove the old jar from the subdirectory. If the driver jar has the same name, replace the original JAR with the updated JAR.

  3. Determine if you need to modify your CLASSPATH:

    • If the JDBC driver JAR was installed with WebLogic Server and the replacement JAR has the same name, you do not need to modify CLASSPATH. The manifest in the weblogic.jar file directly or indirectly includes these files so they will load automatically when the server starts.

    • If you are adding a new JDBC driver or updating a JDBC driver where the replacement JAR has a different name than the original JAR:

      • For all domains, edit the commEnv.cmd/sh script in WL_HOME/common/bin and prepend your JAR file to the WEBLOGIC_CLASSPATH environment variable. Your JAR must be located before any client JAR files. If necessary, remove any references to the original JAR.

      • For a specific WebLogic Server domain, edit the setDomainEnv.cmd/sh script in that domain's bin directory, and prepend the JAR file to the PRE_CLASSPATH environment variable. Your JAR must be located before any client JAR files. If necessary, remove any references to the original JAR.


        setDomainEnv is designed to be sourced from other scripts, such as the startWebLogic script. setDomainEnv should not be called directly from within an interactive shell. Doing so can cause unpredictable issues in the domain.

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 WL_HOME\server\ext\jdbc\oracle\11g 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 WL_HOME\server\ext\jdbc\oracle\11g folder includes the ojdbc6_g.jar (for JDK 6) and ojdbc5_g.jar (for JDK 5) files, 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.

Using the Oracle Thin Driver Over SSL

This section describes how to configure the data source in WebLogic Server when using the Oracle Thin driver over SSL.

To configure the data source in WebLogic Server, perform the following steps.

  1. In the Administration Console navigation pane, click the plus sign to expand Services.

  2. Click the plus sign to expand JDBC.

  3. Select Data Sources.

  4. On the Summary of JDBC Data Sources page, select New.

  5. On the Create a New JDBC Data Source page, provide a JDBC data source name and, optionally, the JNDI name.

    Select Oracle as the database type, and the Oracle database driver (Thin XA or Thin) you want to use.

  6. Click Next.

  7. Select the transaction options, if any. Click Next.

  8. On the Connection Properties page, enter the Database Name, the Host Name, the Port, and the Database User Name and password. These values are used to construct a URL for the data source. You will modify this URL on the next page, but you need to enter values now to proceed. Click Next.

  9. On the Test Configuration page, make the following changes:

    1. Verify that the driver Class Name is oracle.jdbc.xa.client.OracleXADataSource or oracle.jdbc.OracleDriver.

    2. Modify the URL to use the following syntax and format:

      URL : jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = tcps)
      (HOST = <hostname>)(PORT = <sslport>))) (CONNECT_DATA = (SERVICE_NAME = <service_name>))

      (SECURITY=(SSL_SERVER_CERT_DN=\"CN=<.....>\")) is optional and is used only for server DN matching.

  10. Enter (or accept) the Test Table Name.

  11. Optionally, click Test Configuration to test the configuration.

  12. Click Finish.