Find Oracle JDBC driver in Maven repository

前端 未结 22 1281
你的背包
你的背包 2020-11-22 09:28

I want to add the oracle jdbc driver to my project as dependency (runtime scope) - ojdbc14. In MVNrepository site the dependency to put in the POM is:



        
相关标签:
22条回答
  • 2020-11-22 09:59

    Download the jar and place it in your project src/lib. Now you can use the maven installer plugin.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
            <execution>
                <id>install-oracle-jdbc</id>
                <goals>
                    <goal>install-file</goal>
                </goals>
                <phase>clean</phase>
                <configuration>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc6</artifactId>
                    <version>11.2.0</version>
                    <packaging>jar</packaging>
                    <generatePom>true</generatePom>
                    <createChecksum>true</createChecksum>
                    <file>${project.basedir}/src/lib/ojdbc6.jar</file>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    Now you only have to execute mvn clean once and the oracle lib is installed in your local maven repository.

    0 讨论(0)
  • 2020-11-22 10:00

    If you are using Netbeans, goto Dependencies and manually install artifact. Locate your downloaded .jar file and its done. clean build will solve any issues.

    0 讨论(0)
  • 2020-11-22 10:00

    This worked for me like charm. I went through multiple ways but then this helped me. Make sure you follow each step and name the XML files exactly same.

    https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides

    The process is a little tedious but yes it does work.

    0 讨论(0)
  • 2020-11-22 10:02

    How do I find a repository (if any) that contains this artifact?

    Unfortunately due the binary license there is no public repository with the Oracle Driver JAR. This happens with many dependencies but is not Maven's fault. If you happen to find a public repository containing the JAR you can be sure that is illegal.

    How do I add it so that Maven will use it?

    Some JARs that can't be added due to license reasons have a pom entry in the Maven Central repo. Just check it out, it contains the vendor's preferred Maven info:

    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.3.0</version>
    

    ...and the URL to download the file which in this case is http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html.

    Once you've downloaded the JAR just add it to your computer repository with (note I pulled the groupId, artifactId and version from the POM):

    mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
         -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true
    

    The last parameter for generating a POM will save you from pom.xml warnings

    If your team has a local Maven repository this guide might be helpful to upload the JAR there.

    0 讨论(0)
  • 2020-11-22 10:03

    As of today (27, February 2020) Oracle announced that it has published all JDBC client libraries from version 11.2.0.4 (e.g. ojdbc6) to 19.3.0 (e.g. ojdbc10) on Maven Central under the group id com.oracle.database:

    Example:

    <dependency>
      <groupId>com.oracle.database.jdbc</groupId>
      <artifactId>ojdbc10</artifactId>
      <version>19.3.0.0</version>
    </dependency>
    
    0 讨论(0)
  • 2020-11-22 10:03

    I ship opensource under LGPLv2 and even after several email conversations with Oracle they were unclear whether I was allowed to ship their binary JDBC driver with my distribution. The issue related to whether my license was compatible with their OTN terms so they suggested I was not permitted to ship the driver. Presumably related to this part

    (b) to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement

    So even if you manage to publish the driver legally in your exclusive/local maven repository there is still the restriction on what you are permitted to do with that artifact. Seems absurd that even if I ship their driver in binary form along with the full OTN license file I still can't use it and must force my users to manually download the Oracle driver and drop into my library path before they can use my software.

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