How to add Oracle JDBC driver in your Maven local repository

Due to Oracle license restriction, there is NO public Maven repository provides Oracle JDBC driver. To use Oracle jdbc drive with Maven, you have to install it manually into your Maven local repository.

Here’s a guide to show you how to add an Oracle JDBC driver (“ojdbc6.jar“) into your Maven local repository, and also how to reference it in pom.xml.

1. Get Oracle JDBC Driver

Two ways to get the Oracle jdbc driver :

  1. Oracle.com
  2. Oracle database installed folder, for example, “{ORACLE_HOME}\jdbc\lib\ojdbc6.jar

2. Install It

To install your Oracle jdbc driver, issue following command :

mvn install:install-file -Dfile={Path/to/your/ojdbc.jar} -DgroupId=com.oracle 
-DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

See following full example :

D:\>mvn install:install-file -Dfile=D:\app\mkyong\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar 
-DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing D:\app\mkyong\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar to 
D:\maven\repo\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.jar
[INFO] Installing C:\Users\mkyong\AppData\Local\Temp\mvninstall9153984116424557894.pom 
to D:\maven\repo\com\oracle\ojdbc6\11.2.0\ojdbc6-11.2.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.279s
[INFO] Finished at: Thu Apr 21 19:56:37 SGT 2011
[INFO] Final Memory: 2M/4M
[INFO] ------------------------------------------------------------------------

Done, ojdbc6.jar is installed in your Maven local repository.

3. pom.xml

Now, you can reference it by declares following Oracle details in your pom.xml.

File : pom.xml

<project ...>
 
	<dependencies>>
 
		<!-- ORACLE database driver -->
		<dependency>
			<groupId>com.oracle</groupId>
			<artifactId>ojdbc6</artifactId>
			<version>11.2.0</version>
		</dependency>
 
	</dependencies>
</project>

Reference

  1. How to include library manually into Maven local repository
Tags :

About the Author

mkyong
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

  • Pingback: I was reading this()

  • Pingback: I was reading this()

  • Pingback: alkaline water()

  • Pingback: visit site()

  • Pingback: bottled alkaline water()

  • Pingback: water ionizer()

  • Pingback: check that()

  • Pingback: on yahoo()

  • Pingback: house blue()

  • Pingback: zak?ad szklarski piotrk√≥w trybunalski()

  • Pingback: water ionizer loans()

  • Pingback: pay day loans()

  • Pingback: paypal loans()

  • Pingback: alkaline water benefits()

  • Pingback: parking()

  • Pingback: mobile porn movies()

  • Pingback: laan her og nu()

  • Pingback: parking()

  • Pingback: laan penge her og laan penge nu()

  • Pingback: best DIRECTV deals()

  • Pingback: TV for Businesses()

  • Pingback: kagen water()

  • Pingback: kangen water()

  • Pingback: water ionizer()

  • Pingback: water ionizers()

  • Pingback: watch movies online free()

  • Pingback: free movie downloads()

  • Pingback: watch movies online free()

  • Pingback: Blue Coaster33()

  • Pingback: Deb's Desk – Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping)()

  • RM

    Genius. Thanks!

  • http://hanumantechnologies.com Vijay Kumar

    Thanks. It was wonderful!

  • Carlos Gonzaga

    Very good stuff.
    Thank you mkyong

  • Pingback: Oracle 11 XE & JDBC | Li Guoliang()

  • paiker

    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

    • paiker

      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

      • paiker

        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

  • Pingback: install driver oracle ojdbc14-9i ke dalam maven repo | saifiahmada()

  • Pingback: Spring – Oracle Connection Pool Configuration | Peace be with you()

  • mano

    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…

  • http://www.anamikamishra.in anamika mishra

    why not simply add the following repository to your project

    &lt;repositories&gt;
        &lt;repository&gt;
          &lt;id&gt;codelds&lt;/id&gt;
          &lt;url&gt;https://code.lds.org/nexus/content/groups/main-repo&lt;/url&gt;
        &lt;/repository&gt;
      &lt;/repositories&gt;
  • Dauka

    Thank you! You helped me out ^_^

  • Balamurugan

    Hi,
    I have the same problem what sajid is facing. Anyting specific, do I need to do?

  • sajid

    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

  • Ben Weaver

    This and other pages you have put are excellent. Very practical and clear–real time-savers. Thank you.

  • JAY

    This article is nice and simple to understand.

  • http://elres.com.ua/indexz5000.html elres

    ???????????? ?????????? ???????? ?????????????? ? ??????

  • Pingback: Maven 3 + Hibernate 3.6 + Oracle 11g Example (XML Mapping)()