Slippy
Slippy

Reputation: 1343

Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver] in Java application

I have the ojbcd8.jar, and I want to use it locally in my gradle project, which is being developed in intelliJ.

I added the jar to my project as follows :

enter image description here

And I also have the following line in my build.gradle dependencies :

compile files('libs/ojdbc8.jar')

But, when I try to run my application, I get this error :

Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

How do I remedy this?

Upvotes: 0

Views: 1673

Answers (1)

Slippy
Slippy

Reputation: 1343

Found the answer myself, posting it here in case anybody needs it later :

Enable local Maven repository in the build.gradle file:

repositories {  
    mavenCentral()  
    mavenLocal()  
}  

then install the jar :

mvn install:install-file -Dfile=ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
Check that you have the jar installed into your ~/.m2/ local Maven repository

Now, add it to the dependencies in gradle!

dependencies {  
    compile ("com.oracle:ojdbc8:12.2.0.1")  
}  

Done.

Upvotes: 2

Related Questions