How to add Oracle JDBC driver in your Maven local repository
Here’s a guide to show you how to add an Oracle JDBC driver into your Maven local repository, and also how to reference it in pom.xml
.
Note
Due to Oracle license restrictions, the Oracle JDBC driver is not available in the public Maven repository. To use the Oracle JDBC driver with Maven, you have to download and install it manually into your Maven local repository.
Due to Oracle license restrictions, the Oracle JDBC driver is not available in the public Maven repository. To use the Oracle JDBC driver with Maven, you have to download and install it manually into your Maven local repository.
1. Get Oracle JDBC Driver
Two ways to get the Oracle jdbc driver :
1. Visit Oracle website to get the Oracle JDBC driver – ojdbc6.jar
or ojdbc7.jar

2. Not recommend, but you can get the JDBC driver from the Oracle database installed folder, for example – {ORACLE_HOME}\jdbc\lib\ojdbc6.jar
2. Maven Install
To install the Oracle jdbc drivers :
2.1 ojdbc6.jar
$ mvn install:install-file -Dfile={Path/to/your/ojdbc6.jar}
-DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
2.2 ojdbc7.jar
$ mvn install:install-file -Dfile={Path/to/your/ojdbc7.jar}
-DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar
Full example to install a ojdbc7.jar
Terminal
> mvn install:install-file -Dfile=C:\\OracleJDBC\\ojdbc7.jar
-DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing C:\OracleJDBC\ojdbc7.jar to C:\Users\mkyong\.m2\repository\com\oracle\ojdbc7\12.1.0\ojdbc7-12.1.0.jar
[INFO] Installing C:\Users\mkyong\AppData\Local\Temp\mvninstall2095378400735903278.pom
to C:\Users\mkyong\.m2\repository\com\oracle\ojdbc7\12.1.0\ojdbc7-12.1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.332 s
[INFO] Finished at: 2017-02-13T21:26:03+08:00
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
Done.
3. pom.xml
pom.xml
<dependencies>
<!-- ojdbc6.jar example -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<!-- ojdbc7.jar example -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
</dependencies>
Leave a Reply
com.oracle
ojdbc6
11.2.0
missing arifects in pom.xml
I have the similar issue say this “artifactId missing”
I believe it is because oracle does not allow their driver to be on maven repo site anymore. Need to be added manually. (Or so I believe)
Thank you so much! All your post are amazing!
thanks lot
I want to recommend you’re an exellent resource, thanks mkyong !!
Thank you, you saved me.
Thank you very much
Thanks so much dude! All your work are so great! Keep it up! :D
Great!!
If you want ojdbc, What you can do is download the ojdbc6.jar and include it as a “Web App Libraries” by Right Clicking your project and select java build path and under Libraries select Add external jars and select the location to the jar that you have downloaded (ojdbc6.jar).
Please not this instruction is given for Eclipse.
Thanks, very helpful
am getting this error ..please help me out :-
mvn install:install-file -Dfile=D:oraclexeapporacleproduct11.2.0serverjdbclib -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
[…] For Oracle JDBC Driver Read this guide – How to add Oracle JDBC driver in your Maven local repository […]
I’m newbie in this framework. can you tell me where i should execute mvn install command in windows?
try out in cmd..dos prompt
Genius. Thanks!
Thanks. It was wonderful!
Very good stuff.
Thank you mkyong
[…] [http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/] […]
I am getting the below exception, could you please suggest.
[ERROR] Failed to execute goal on project SpringExamplesDAO: Could not resolve dependencies for project com.mkyong.common:SpringExamplesDAO:jar:1.0-SNAPSHOT: Could not find artifact com.oracle:ojdbc6:jar:11.2.0 in central (http://repo.maven.apache.org/maven2) -> [Help 1]
Though i already installed ojdbc6.jar in local .m2
Can anyone please help me as , my maven is not picking up the com.oracle:ojdbc6:jar:11.2.0 jar from local repository within .m2/
It is pointing to maven repository from internet and it doesn’t find jar there, though i have registered it there in .m2/ with the help of above procedure
Guys,
Problem has been solved now, there was some version problem,
I had jdk1.6 with maven-3.0.4.
Now i have installed Maven 2.2.1, and problem has been solved.
Thanks
[…] [1] http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ [2] […]
[…] http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ […]
Hi mkyong…
the jdbc driver jar is not getting installed in m2 repository when i am executing the command ..
mvn install:install-file -Dfile=C:\app\msarilla\product\11.2.0\dbhome_2\jdbc\lib\ojdbc6.jar -DgroupId=com.oracle – DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar -DgeneratePom=true
when i execute the command the build was successful but the ojdbc6 file is not installed to the m2 repo.
i am getting the following message in the build console:
[INFO] Installing C:\apache-maven-3.0.4\bin\ojdbc6.jar to C:\Users\msarilla\.m2\
repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.jar
[DEBUG] Skipped re-installing C:\apache-maven-3.0.4\bin\ojdbc6.jar to C:\Users\m
sarilla\.m2\repository\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.jar, seems unchang
ed..
from the above messages i can see that the jar installation is skipped coz its already there..but actually there is no ojdbc6 jar…
any suggestions…
why not simply add the following repository to your project
Thank you! You helped me out ^_^
Hi,
I have the same problem what sajid is facing. Anyting specific, do I need to do?
Hi, i completed the steps above, but still facing ‘Missing artifact com.oracle:ojdbc6:jar:11.2.0.3:compile’.
Also, after step 2, i think the jar file should be automatically placed in repository, but it doesnt happen and i can see only _maven.repositories, ojdbc6-11.2.0.3.pom and ojdbc6-11.2.0.3.jar.lastUpdated. Is there anything that i am missing.
Thanks.
sajid
This and other pages you have put are excellent. Very practical and clear–real time-savers. Thank you.
This article is nice and simple to understand.
???????????? ?????????? ???????? ?????????????? ? ??????
[…] For Oracle JDBC driver, you need to install it into your local maven repository manually. For Oracle JDBC Driver Read this guide – How to add Oracle JDBC driver in your Maven local repository […]
Thank you for sharing!