Tuesday, August 23, 2016

Add Oracle JDBC Driver in 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
There are two different ways to get the Oracle jdbc driver :
a. go to Oracle.com and find it.
b. Oracle database installed folder, for example, “{ORACLE_HOME}\jdbc\lib\ojdbc6.jar“
that is,
go to C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib and find ojdbc5.jar or ojdbc6.jar

2. Install OJDBC driver:
To install your Oracle jdbc driver, enter the following command :
mvn install:install-file -Dfile={Path/to/your/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar

Or,
go to C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib and find ojdbc5.jar or ojdbc6.jar
copy ojdbc5.jar file and put in c:\temp folder
open cmd/terminal window from c:\temp folder and enter the following command:
mvn install:install-file -Dfile=ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.3 -Dpackaging=jar

Once you execute the code, you will see the following message:
C:\TEMP>mvn install:install-file -Dfile=ojdbc5.jar -DgroupId=com.oracle -DartifactId=ojdbc5 -Dversion=11.2.0.3 -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:\TEMP\ojdbc5.jar to C:\Users\meVeekay\.m2\repository\com\oracle\ojdbc5\11.2.0.3\ojdbc5-11.2.0.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.220 s
[INFO] Finished at: 2016-07-18T15:41:03-06:00
[INFO] Final Memory: 7M/77M
[INFO] ------------------------------------------------------------------------

3. Now, You are all set! Oracle JDBC Driver ojdbc5.jar is installed in your Maven local repository.

4. Now you can reference it by adding the following Oracle details in your pom.xml:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc5</artifactId>
<version>${oracle.version}</version>
</dependency>


================================
For dependency:

google: maven hibernate entitymanager
(deprecated Use Hibernate Core Instead) Hibernate JPA Support » 5.2.1.Final)

No comments:

Post a Comment