How to add an Oracle JDBC driver to your maven repository

We are going to see how to add an Oracle JDBC driver in your local Maven repository and how to reference it in your pom.xml.

We are going to see how to add an Oracle JDBC driver in your local Maven repository and how to reference it in your pom.xml.

1. Download the Oracle JDBC driver

You have to go to the Oracle site to get the Oracle JDBC driver. Choose the right version of the jar. Example ojdbc6.jar or ojdbc7.jar

2.Settling in Maven

To install the Oracle jdbc drivers you have to go to the terminal and put the following command:mvn install:install-file -Dfile={Path/to/your/ojdbc6.jar}
     -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

3.Setting the pom.xml

In your pom add now the dependency :<dependencies>...
       <!-- ojdbc6.jar example -->
       <dependency>
           <groupId>com.oracle</groupId>
           <artifactId>ojdbc6</artifactId>
           <version>11.2.0</version>
       </dependency>

       ...

</dependencies>

NB : Note that for the jar ojdbc7.jar the version in the pom becomes: <version>12.1.0</version>

Takk Jokk