The Oracle OJDBC JAR is a common dependency for anyone wanting to connect to an Oracle database from Java. Oracle has a Maven repository that you can add to download Oracle JDBC drivers and other Oracle JARs. However not all of Oracle’s JARs (notably including OJDBC6) are not available on their Maven repository.
Additionally it may be difficult to add an additional Maven repository to your configurations for a variety of reasons. An alternative approach is to deploy Oracle JARs to your own private Maven repository.
Deploying ojdbc6 to a Maven repository
First you need to download the JAR. For this example we’ll use
ojdbc6.jar and store it in a new directory called
lib. You can download current versions from Oracle’s website. Once you have the JAR you can use Maven to deploy it to your own private Maven repository.
mvn deploy:deploy-file \ -DgroupId=com.oracle.jdbc \ -DartifactId=ojdbc6 \ -Dversion=184.108.40.206 \ -Dpackaging=jar \ -Dfile=lib/ojdbc6.jar \ -DrepositoryId=releases \ -Durl=https://repo.deps.co/acme/releases \ --settings settings.xml
Adding ojdbc6 to your local Maven repository
If you are working locally and don’t need others to be able to access this JAR, you can instead add the ojdbc6 JAR to your local Maven repository. You can again do this using the Maven command line tool.
mvn install:install-file \ -DgroupId=com.oracle.jdbc \ -DartifactId=ojdbc6 \ -Dversion=220.127.116.11 \ -Dpackaging=jar \ -Dfile=lib/ojdbc6.jar
If you don’t currently have a private Maven repository, and don’t want to deal with managing it yourself, you can sign up for Deps so we can manage it for you.
Notes on copyright
While we are not lawyers, it is our understanding that you are not allowed to publish Oracle’s JARs to a public Maven repository like Maven Central or Bintray. Please only publish these JARs to private Maven repositories that you control.