How to add third-party JDBC drivers on WebLogic

Oracle WebLogic data sources supports many databases types by default and also comes with some JDBC drivers for most of them.

But, not very often, you are working with third-party databases (non-Oracle) and endup needing to download the JDBC drivers from the database provider and doing the setup on WebLogic by yourself. The steps are pretty simple, but some still have questions on how to do it and I will try to create a step-by-step guide on this post.

In this example, the environment is Oracle WebLogic 12c running on a Mac OS X and doing the simulation of a Microsoft SQL Server JDBC Driver installation.

To simulate the issue of a missing driver, try to create a new Data Source selecting the following parameters on a default installation:

  • Database Type: MS SQL Server
  • Database Driver: Microsoft’s SQL Server Driver (Type 4) Version: 2005 and later

Complete the wizard with your database access information (host, port, username, password) and try to Test the Connection before saving. You should see the error below stating that you don’t have the driver classes on the classpath.

Image

Ok, let’s setup the JDBC driver:

      1. Download the JDBC Driver – MS SQL Server JDBC drivers are currently hosted on this link: http://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx
      2. Unpack the zip or tarball with the JDBC driver jar file and copy the specified file to the WebLogic installation directory, under the ${WL_HOME}/server/lib folder.
        (markito@luke)$ tar -xzvpf sqljdbc_4.0.2206.100_enu.tar.gz
        (markito@luke)$ cd sqljdbc_4.0/enu/
        (markito@luke)$ cp sqljdbc.jar ${WL_HOME}/server/lib/
        
      3. Now, modify the commEnv.sh script. This script sets common environment variables for WebLogic and set the WebLogic classpath with some base libraries from the WebLogic installation directory.
        The file is located under: ${WL_HOME}/common/bin/commEnv.shBefore:

        # set up WebLogic Server's class path
        WEBLOGIC_CLASSPATH="${JAVA_HOME}/lib/tools.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.
        jar${CLASSPATHSEP}${FEATURES_DIR}/weblogic.server.modules_13.1.1.0.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.
        jar${CLASSPATHSEP}${ANT_HOME}/lib/ant-all.
        jar${CLASSPATHSEP}${ANT_CONTRIB}/lib/ant-contrib.jar"
        export WEBLOGIC_CLASSPATH
        

        After:

        # set up WebLogic Server's class path
        WEBLOGIC_CLASSPATH="${JAVA_HOME}/lib/tools.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.
        jar${CLASSPATHSEP}${FEATURES_DIR}/weblogic.server.modules_13.1.1.0.
        jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.
        jar${CLASSPATHSEP}${ANT_HOME}/lib/ant-all.
        jar${CLASSPATHSEP}${ANT_CONTRIB}/lib/ant-contrib.jar
        <strong>jar${CLASSPATHSEP}${WL_HOME}/server/lib/sqljdbc4.jar"
        export WEBLOGIC_CLASSPATH
        
      4. Now restart the WebLogic server and repeat the process to create a new MS SQL Server data source.

There is a bonus step which is not always required – Since you’re using a new JDBC driver, sometimes you don’t have the entry under WebLogic database drivers list. To update this list modify the ${WL_HOME}/server/lib/jdbcdrivers.xml file accordingly, the description of the file is very explanatory:

<!-- This xml file contains meta information regarding JDBC Driver's and making connections to the DBMS.
It is designed to hold information so that UI can gather information from a user and configure
The Driver classname, The Driver URL and the driver Properties to make a connection to the DBMS

This XML entry is a required peice of data that could be required in the URL or in the properties object

       There are 5 well known property names:
       DbmsHost
       DbmsPort
       DbmsName
       DbmsUsername
       DbmsPassword

       Properties that don't match the well know ones above, will be passed as name=value pairs to either
       the URL or the properties object (based on InURL=false or true.

       Then the UI would prompt:
       Please Enter
       Database Type : normal
       This is required to Indicate your DB type.
       And after the user providing it the UI would stuff it into the JDBCDriverInfo object and the JDBCURLHelper would do the right thing with it
       stick it in the URL or in the properties object
--!>

Remember that although you can add or update third-party drivers, you should still follow the supported database list provided by the WebLogic Certification Matrix in order to keep with a supported installation.

References:

http://docs.oracle.com/cd/E24329_01/web.1211/e24367/third_party_drivers.htm

3 thoughts on “How to add third-party JDBC drivers on WebLogic

  1. There is no much difference for these commands on windows. For instance, the weblogic shell scripts has equivalent files with .cmd prefix – The difference will actually be the paths, since you would need to switch to forward slashes (‘\’ – ‘/’) on paths. If you have questions about an specific part on windows, please let me know.

  2. i have the same issue on weblogic 12.2/windows/SQL and i performed the same steps(downloaded the SQLjdbc4.jar and added the path in the weblogic classpath) but not able to resolve it .
    any suggestions ?– i have performed the restarts on weblogic and the PC but no result — is it caching?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s