Maven – Add Oracle JDBC Driver to Repository

When we use Maven we don´t want to install the ojdbc.jar directly in our project. We also want to add this via dependency.
Oracle isn´t placing he ojdbc driver by them self in the maven repository. Honestly Oracle – why?
If your project is placed in a company you may have a company specific maven repository which already contains a driver jar. Otherwise we need to add it to our local maven repository.


First of all we need to download the ojdbc driver from the official Oracle Page.
To accomplisis this follow this link. You need to accept the License Agreement.
I recommend to you to download the latest version you find.
After the download finished place your driver to any directory you want.

Install the Driver

Please open the Command Line Interface of your choice and navigate to the directory where you put the driver.

When you are in the directory of the driver you need to find out which version number the driver has. For this just look again at the download page of Oracle. On the top of the page you´ll find the version number

That´s the version number you´ll need for the following command in your CLI.

mvn install:install-file -Dfile=ojdbc8.jar -DartifactId=ojdbc8 -Dversion= -Dpackaging=jar

After you hit the Enter Button the process will beginn to run. And maven will install the .jar to your local repository.


After all you should have an output equal to this one

$ mvn install:install-file -Dfile=ojdbc8.jar -DartifactId=ojdbc8 -Dversion= -Dpackaging=jar
[INFO] Scanning for projects...
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing C:\Users\javadevcorner\Downloads\ojdbc8.jar to C:\Users\javadevcorner\.m2\repository\com\oracle\ojdbc8\\ojdbc8-
[INFO] Installing C:\Users\javadevcorner\AppData\Local\Temp\mvninstall3128178970450022048.pom to C:\Users\javadevcorner\.m2\repository\com\oracle\ojdbc8\\ojdbc8-
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.557 s
[INFO] Finished at: 2018-07-27T19:38:47+02:00
[INFO] ------------------------------------------------------------------------

Add to pom.xml

Now, after we have added this driver to our local repository we can add it to our pom.xml




Of course this technique is not only working for ojdbc drivers. You can add any .jar to your maven repository and make it use by that.

Thanks for reading and have fun adding your ojdbc driver and some other jars to your maven repository

Feel free to share

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.