How to add OJDBC jar to Maven Repository

By | 2019-03-31T20:34:48+05:30 March 31st, 2019|maven|

This guide helps you to understand how to add OJDBC jar to Maven repository.

How to add OJDBC jar to Maven Repository:

Unfortunately due to the Oracle binary licensing restrictions, the ojdbc driver jar is not available on Maven public repository. If you find this jar any public repository probably its illegal. So that we can not directly access ojdbc jar from Maven repository.

In this tutorial, we will see how to add ojdbc jar into our local maven repository.

1. Get OJDBC jar:

Download the latest ojdbc jar (For me it is ojdbc8.jar) from Oracle’s website.

How to add OJDBC jar to Maven Repository

2. Install Maven:

Execute the below maven command to install ojdbc and adding it into your local maven local repository.

$ mvn install:install-file -Dfile={your_path/ojdbc8.jar} 
-DgroupId=com.oracle -DartifactId=jdbc8 -Dversion=12.2.0.1 -Dpackaging=jar

Specify your ojdbc(6 or 7 or 8).jar to -Dfile=PATH.

Example:

Terminal
cgoka@work:~/Documents/Work/maven$ mvn install:install-file -Dfile=/home/cgoka/Softwares/ojdbc8.jar -DgroupId=com.oracle -DartifactId=jdbc8 -Dversion=12.2.0.1 -Dpackaging=jar -X
Apache Maven 3.5.2
Maven home: /usr/share/maven
Java version: 11.0.2, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-11-oracle
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-46-generic", arch: "amd64", family: "unix"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
....
....
[DEBUG] (f) version = 12.2.0.1
[DEBUG] -- end configuration --
[DEBUG] Installing generated POM
[INFO] Installing /home/cgoka/Softwares/ojdbc8.jar to /home/cgoka/.m2/repository/com/oracle/jdbc8/12.2.0.1/jdbc8-12.2.0.1.jar
[DEBUG] Writing tracking file /home/cgoka/.m2/repository/com/oracle/jdbc8/12.2.0.1/_remote.repositories
[INFO] Installing /tmp/mvninstall6894711908436548564.pom to /home/cgoka/.m2/repository/com/oracle/jdbc8/12.2.0.1/jdbc8-12.2.0.1.pom
[DEBUG] Writing tracking file /home/cgoka/.m2/repository/com/oracle/jdbc8/12.2.0.1/_remote.repositories
[DEBUG] Installing com.oracle:jdbc8/maven-metadata.xml to /home/cgoka/.m2/repository/com/oracle/jdbc8/maven-metadata-local.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Its Done.

3. Pom.xml

Access ojdbc8.jar from application’s pom.xml like below.

pom.xml
 <dependencies>
  <dependency>
  <groupId>com.oracle</groupId>
  <artifactId>jdbc8</artifactId>
  <version>12.2.0.1</version>
  </dependency>
</dependencies>

References:

Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment