Maven ojdbc jar dependency error: package oracle.jdbc does not exist

后端 未结 5 1572
孤城傲影
孤城傲影 2021-01-17 16:29

Heading

Am trying to use jdbc connection in my Java EE6 application(class name VisualizerRepository.java), i have the jdbc driver in nexus repository

The c

相关标签:
5条回答
  • 2021-01-17 17:02

    Oracle JDBC drivers are accessible from Oracle Maven Repository with some additional security related steps.
    Check the blog "Get Oracle JDBC drivers and UCP from Oracle Maven Repository (without IDEs)" for more details.

    0 讨论(0)
  • 2021-01-17 17:08

    The maven command that resides in answer

    (meanwhile it was taken from http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/) did not work for me. But after removing {} characters, everything is fine:

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

    Also don't forget to add version number to the name of jar file like ojdb6-11.2.0.jar

    0 讨论(0)
  • 2021-01-17 17:15

    The ojdbc jar is not in public maven repositories. You can add the jar to local repository manually.

    Download the jar from:

    • oracle site
    • copy from your oracle database server ( {ORACLE_HOME}\jdbc\lib\ojdbc6.jar )

    Install in your repository

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

    Use in your pom

       <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0</version>
       </dependency>
    
    0 讨论(0)
  • 2021-01-17 17:16

    I tried to get gradle to pull the jar from my local maven repo and even using flatDir in the repositories closure, but to no effect. In the end, I created a lib folder in my project and put the jar in it and added

    dependencies {
        ...
        compile files('lib/ojdbc7.jar')
        ...
    }
    

    I don't think this is the prettiest way to handle it, but it worked, and it's good enough for now.

    0 讨论(0)
  • 2021-01-17 17:17

    I faced a similar scenario where exception was following.

    java: cannot access oracle.jdbc.OracleTypes error
    

    I manually installed ojdbc JAR to my local repository. However the problem was still existing. It was because I installed ojbc10.jar. For some reasons I thought number in this JAR name is like JDBC version. But they are more related with Java version. My project was using Java JDK 8. So issue got resolved after installing ojdbc8.jar.

    So when you download make sure to check the release note. Certified with JDK8, JDK9, JDK11.

    0 讨论(0)
提交回复
热议问题