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 :

Oracle.com
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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值