X

Learn Tips and Best Practices from the Oracle JDBC Development

  • February 15, 2016

Get Oracle JDBC drivers and UCP from Oracle Maven Repository (without IDEs)

Nirmala Sundarappa
Principal Product Manager

New !! Oracle 19.3 JDBC drivers and Universal Connection Pool (ucp.jar) are on Maven Central Repository !! Refer to the blog for more details. 

The Oracle JDBC drivers and Universal Connection Pool (UCP) are also available on the Oracle Maven Repository. The following versions are available on the Oracle Maven repository:  19.3.0.0., 18.3.0.0, 12.2.0.1, 12.1.0.2, 12.1.0.1, and 11.2.0.4. In addition, the companion jars including simplefan.jar, ons.jar, orai18n.jar etc., required for specific features are also available. 

GAV details for ojdbc8.jar from 19.3.0.0:

<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>

Here is the list of artifacts available on Oracle Maven repository:
<groupid> is the same for all versions. Make sure to change the <artifactid> and <version> to the exact jar that you want to download.

  • ojdbc8.jar: JDBC driver certified with JDK8
  • ucp.jar: Universal Connection Pool to use with JDK8
  • orai18n.jar: Classes for NLS or Internalization support
  • simplefan.jar: Java APIs for subscribing to RAC events via ONS
  • ons.jar: Oracle Notification Services (ONS) daemon
  • osdt_core.jar, osdt_cert.jar, oraclepki.jar: Required to access Oracle Wallets from Java
  • xdb6.jar and xmlparserv2.jar: To support standard java.sql.SQLXML interface
  • ojdbc8_g.jar: Same as ojdbc8.jar except compiled with "javac -g" and contains tracing code
  • ojdbc8dms.jar: Same as ojdbc8.jar, except that it supports DMS and limited java.util.logging calls
  • ojdbc8dms_g.jar: Same as ojdbc8_g.jar except that it contains instrumentation to support DMS.

Refer to Get Oracle JDBC drivers and UCP from the Oracle Maven Repository - NetBeans, Eclipse, Intellij for steps while using NetBeans, Eclipse, and Intellij.  Follow the steps mentioned in this blog to successfully download the required version of Oracle JDBC drivers, UCP, or any other companion jars. 

Step #1: Download Maven

  • Install Apache Maven if you do not have it already. 
  • Update M2_HOME and JAVA_HOME environment variables:
    Make sure to update M2_HOME to point to the path where Maven is installed and JAVA_HOME to point to the location where the JDK is installed. If you require a specific Java version then set it using these system arguments.
    -Dmaven.compiler.source=1.8 -Dmaven.compiler.target=1.8

Step#2: Registering with the Oracle Maven site

The Oracle Maven repository requires a valid user registration and the user should also accept the terms and conditions (T&Cs) by logging into http://maven.oracle.com. This username will be used in settings.xml.

Step#3: Create a settings-security.xml

Create a settings-security.xml file that holds the master password information under the local  maven repository (Example: {USER_HOME}/.m2/ ) that is usually under the user home directory.  For example: If the username is test then the path will be

  • Unix : /home/test/.m2/settings.xml
  • Windows : C:\Users\test\.m2\settings.xml
Use the following commands to generate a master password and add the output of this command to settings-security.xml as shown in the sample
mvn -encrypt-master-password <any_master_password> or
mvn -emp <any_master_password>
Sample settings-security.xml:
<settingsSecurity> 
<master>{By8wW7YcTxAHof0MF4Z3wPKboywhGJvxHD9m0NvHA2U=}</master> 
</settingsSecurity> 

Step#4: Create a settings.xml file

The settings.xml file is required for downloading Oracle JDBC drivers and UCP.  Encrypt the user password (the one used to accept T&Cs on http://maven.oracle.com) before using it in settings.xml.  Use the following commands to encrypt the user password and update settings.xml as shown in the sample
mvn -encrypt-password <oracle_registered_password> or mvn -ep <oracle_registered_password>

Sample settings.xml:
<settings>
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.mycompany.com</host>
      <nonProxyHosts>mycompany.com</nonProxyHosts>
   </proxy>
  </proxies>

<servers>
  <server>
    <id>maven.oracle.com </id>
    <username>firstname.lastname@test.com</username>
    <password>{pnwmhVnzdM8H3UAneUKLmaHGZCoaprbMQ/Ac5UktvsM=}</password>
  <configuration>
    <basicAuthScope>
      <host>ANY </host>
      <port>ANY </port>
      <realm>OAM 11g </realm>
    </basicAuthScope>
    <httpConfiguration>
      <all>
      <params>
        <property>
          <name>http.protocol.allow-circular-redirects </name>
          <value>%b,true </value>
        </property>
      </params>
      </all>
    </httpConfiguration>
  </configuration>
  </server>
  </servers>
</settings>

Create a project and test Maven download

Step#1: Create a pom.xml and specify GAV for JDBC drivers and UCP

Add the following GAV details for downloading JDBC driver or UCP from the required version.
<dependencies>
  <dependency>
    <groupId>com.oracle.jdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>maven.oracle.com</id>
    <name>oracle-maven-repo</name>
    <url>https://maven.oracle.com</url>
    <layout>default</layout>
    <releases>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </releases>
  </repository>
</repositories>
<pluginRepositories>
  <pluginRepository>
    <id>maven.oracle.com</id>
    <name>oracle-maven-repo</name> 
    <url>https://maven.oracle.com</url>
    <layout>default</layout>
    <releases>
      <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </releases>
  </pluginRepository>
</pluginRepositories>

Step#2: Create 'src' and 'target' directories

All Java source files must be placed under src directory. Example: /src/main/java/<foldername>/<filename>
In addition, create a target directory where the compiled classes will be placed.

Step#3: Compile the Maven Project

Use the following commands to compile or install or package to test the download.
"mvn –s settings.xml package" or "mvn -s settings.xml compile" or "mvn -s settings.xml install"

The output of a successful download will look as shown below:

➜  test mvn -s settings.xml compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jdbc-driver-prod 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/12.2.0.1/ojdbc8-12.2.0.1.pom
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/12.2.0.1/ojdbc8-12.2.0.1.pom (7 KB at 1.0 KB/sec)
Downloading: https://maven.oracle.com/com/oracle/jdbc/ucp/12.2.0.1/ucp-12.2.0.1.pom
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ucp/12.2.0.1/ucp-12.2.0.1.pom (6 KB at 3.0 KB/sec)
....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.248 s
[INFO] Finished at: 2017-04-28T15:25:49-07:00
[INFO] Final Memory: 11M/202M
[INFO] -----------------------------

 

➜  maven-repo-prod mvn -s settings.xml package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jdbc-driver-prod 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/18.3.0.0/ojdbc8-18.3.0.0.pom
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/18.3.0.0/ojdbc8-18.3.0.0.pom (7 KB at 1.2 KB/sec)
Downloading: https://maven.oracle.com/com/oracle/jdbc/ucp/18.3.0.0/ucp-18.3.0.0.pom
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ucp/18.3.0.0/ucp-18.3.0.0.pom (6 KB at 1.2 KB/sec)
Downloading: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/18.3.0.0/ojdbc8-18.3.0.0.jar
Downloading: https://maven.oracle.com/com/oracle/jdbc/ucp/18.3.0.0/ucp-18.3.0.0.jar
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ucp/18.3.0.0/ucp-18.3.0.0.jar (1366 KB at 218.5 KB/sec)
Downloaded: https://maven.oracle.com/com/oracle/jdbc/ojdbc8/18.3.0.0/ojdbc8-18.3.0.0.jar (4065 KB at 224.8 KB/sec)
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ jdbc-driver-prod ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.240 s
[INFO] Finished at: 2018-09-28T16:24:42-07:00
[INFO] Final Memory: 16M/54M
[INFO] ------------------------------------------------------------------------

Step#4: Check the downloaded JDBC drivers and UCP

If the build was successful, then the JARs and POMs will be downloaded onto the local maven repository at ~/.m2/repository/com/oracle/jdbc/ojdbc8/19.3.0.0/ . Note that ojdbc8.jar will download ucp.jar as well. Each download has its own JAR and POM files.

Sample output:

➜  jdbc pwd
/Users/test/.m2/repository/com/oracle/jdbc
➜  jdbc ls -lt
total 0
drwxr-xr-x  3 nbsundar  staff  96 Sep 28 16:24 ucp
drwxr-xr-x  3 nbsundar  staff  96 Sep 28 13:44 ojdbc8

Join the discussion

Comments ( 3 )
  • Rahul Tuesday, October 2, 2018
    Thank you
  • Markus Schneider Monday, November 12, 2018
    Dear Nirmala Sundarappa,

    are the libs referenced in orai18n.jar manifest also available in Maven ojdbc8 - 18.3.0.0?

    - gdk_custom.jar
    - orai18n-mapping.jar
    - orai18n-utility.jar
    - orai18n-collation.jar
    - orai18n-translation.jar
    - orai18n-net.jar
    - orai18n-servlet.jar
    - orai18n-lcsd.jar
    - orai18n-tools.jar

    From service ticket SR #3-18414536941 I have learned that I need to download them from the 4.4 GByte database installation ZIP file ($ORACLE_HOME/jlib).
    Is the gdk_custom.jar located %ORACLE_HOME%mdproperty_graphlib the correct one for 18.3?

    Thx, Markus
  • Nirmala Sundarappa Thursday, November 15, 2018
    Hi Markus,

    We do not post other manifest files of orai18n.jar. The files that are available on OTN (https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/jdbc-ucp-183-5013470.html) are the ones that are available on Oracle Maven as well.

    Please download the other files from $ORACLE_HOME/lib.

    Regards,
    Nirmala
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.