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.

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>

References

  1. How to include library manually into Maven local repository