Amir Roodaki
Amir Roodaki

Reputation: 39

Why some jar file not build?

<dependency>
    <groupId>oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>

This dependency not be downloaded. What am I doing?

Upvotes: 0

Views: 71

Answers (3)

Nirmala
Nirmala

Reputation: 1338

Yes, Oracle JDBC drivers will be available on central maven. 19.3 version is currently available and other versions will follow soon. Refer to this blog for more details. Also, check out the Maven repo to browse the available jars.

Upvotes: 0

Robert Dean
Robert Dean

Reputation: 681

This has already been covered on another question, but there's new information.

Oracle Maven Repository

Starting in 2016, Oracle started posting its drivers to a secure Oracle Maven repository, and they post the instructions for how to use the repository on their site. The process looks like this:

  1. Register for the site, if needed.
  2. Create a Maven Master password for encryption, if needed.
    mvn -emp [YOUR MASTER PASSWORD]
    
  3. Add the Oracle server to your Maven settings.xml (~/.m2/settings.xml).
    <servers>
      <server>
        <id>maven.oracle.com </id>
        <username>YOUR ORACLE USERNAME</username>
        <password>YOUR ORACLE PASSWORD</password>
      <configuration>
        <basicAuthScope>
          <host>ANY </host>
          <port>ANY </port>
          <realm>OAM 11g </realm>
        </basicAuthScope>
        <httpConfiguration>
          <all>
          <params>
            <property>
              <name>http.protocol.allow-circular-redirects </name>
              <value>%b,true </value>
            </property>
          </params>
          </all>
        </httpConfiguration>
      </configuration>
      </server>
    </servers>
    
  4. Encrypt the Oracle password using Maven:
    mvn -ep [YOUR ORACLE PASSWORD]
    
  5. Add repositories to your Maven POM or settings.xml:
    <repositories>
      <repository>
        <id>maven.oracle.com</id>
        <name>oracle-maven-repo</name>
        <url>https://maven.oracle.com</url>
        <layout>default</layout>
        <releases>
          <enabled>true</enabled>
          <updatePolicy>always</updatePolicy>
        </releases>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
        <id>maven.oracle.com</id>
        <name>oracle-maven-repo</name> 
        <url>https://maven.oracle.com</url>
        <layout>default</layout>
        <releases>
          <enabled>true</enabled>
          <updatePolicy>always</updatePolicy>
        </releases>
      </pluginRepository>
    </pluginRepositories>
    

After you do this, Maven will be able to resolve the dependencies.

Maven Central

As of September 2019, Oracle has started posting its jars to Maven Central. If you can use those versions, then you can just update your dependency:

<dependency>
  <groupId>com.oracle.ojdbc</groupId>
  <artifactId>ojdbc8</artifactId>
  <version>19.3.0.0</version>
</dependency>

Upvotes: 2

emont01
emont01

Reputation: 3230

Oracle drivers can't be installed using maven, as stated by the author of this blog post:

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 into your Maven local repository manually.

You have to download the correct drivers manually and then you can take one of two possible paths, namely:

  1. Install the driver in your local maven repository
  2. Define your dependency indicating the path to the jar file

Here a some examples of both cases:

Local maven repository

  • Download and extract the driver jar in your file system,
  • Then execute the following command
mvn install:install-file -Dfile=path/to/your/ojdbc6.jar -DgroupId=com.oracle 
    -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar
  • Finally adjust your dependency, please notice that I have used a different groupId
<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>

Indicating the location of the jar file

This is quite simple and straight to the point, just put the jar file in some folder and indicate the path in your dependency, you can even use any project path but you will have to be careful with possible legal issues about the driver license or distribution rules; so I recommend you using the first option.

<dependency>
  <groupId>com.oracle</groupId>
  <artifactId>ojdbc6</artifactId>
  <version>6</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
</dependency>

As this process needs to be repeated in every development machine, is worth to mention that you should leave some form of documentation indicating the need of this driver and the necessary steps to install it.

Regards

Upvotes: 0

Related Questions