Monday 17 August 2015

How to add Oracle JDBC Driver in Your Maven local repository

In this post i am going to show you how to install ojdbc.jar under 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.

Step 1: How to get ojdbc.jar?

  • Download ojdbc.jar from oracle website or any other websites.
  • Or you can use the ojdbc.jar from your oracle database installed directory.
Step 2: Install ojdbc.jar in Maven local Repository.

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


So, For me the directory is D:\ojdbc6-11.2.0.3.jar. So the maven install look like
mvn install:install-file -Dfile=D:\ojdbc6-11.2.0.3.jar -DgroupId=com.oracle 
-DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar

Once Your build success check the ojdbc.jar under your maven local repository.

Step 3: pom.xml

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

That's all Folks..