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} -DartifactId=jdbc8 -Dversion= -Dpackaging=jar

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


[email protected]:~/Documents/Work/maven$ mvn install:install-file -Dfile=/home/cgoka/Softwares/ojdbc8.jar -DartifactId=jdbc8 -Dversion= -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$ReflectUtils$1 (file:/usr/share/maven/lib/guice.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,
WARNING: Please consider reporting this to the maintainers of$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 =
[DEBUG] -- end configuration --
[DEBUG] Installing generated POM
[INFO] Installing /home/cgoka/Softwares/ojdbc8.jar to /home/cgoka/.m2/repository/com/oracle/jdbc8/
[DEBUG] Writing tracking file /home/cgoka/.m2/repository/com/oracle/jdbc8/
[INFO] Installing /tmp/mvninstall6894711908436548564.pom to /home/cgoka/.m2/repository/com/oracle/jdbc8/
[DEBUG] Writing tracking file /home/cgoka/.m2/repository/com/oracle/jdbc8/
[DEBUG] Installing to /home/cgoka/.m2/repository/com/oracle/jdbc8/maven-metadata-local.xml
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------

Its Done.

3. Pom.xml

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



Happy Learning 🙂