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 Xand 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.

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.
      1
      2
      3
      (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:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      # 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:
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      # 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
      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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- 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:

留言

這個網誌中的熱門文章

Disable ionic's sidemenu content drag to toggle menu

Multiple writable mappings exist for the field. Only one may be defined as writable, all others must be specified read-only.

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser