Polyphase29
Polyphase29

Reputation: 503

Failed to load driver class oracle.jdbc.OracleDriver in either of HikariConfig class loader or Thread context

I'm working with Spring for the first time and trying to set it up so that my code can access an Oracle database. I have the following configuration in my application.properties:

spring.datasource.url=jdbc:oracle:thin:@140.192.30.237:1521:def
    spring.datasource.username=<username>
    spring.datasource.password=<password>
    spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

My pom.xml contains the following dependencies:

<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.oracle.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>12.2.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>LATEST</version>
    </dependency>
    <dependency>
        <groupId>javax.json</groupId>
        <artifactId>javax.json-api</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>

Yet I get the following error and am not sure how to solve it, I"ve found similar ones from searching but none that have solved my problem:

Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:

    Property: driverclassname
    Value: oracle.jdbc.OracleDriver
    Origin: "driverClassName" from property source "source"
    Reason: Failed to load driver class oracle.jdbc.OracleDriver in either of HikariConfig class loader or Thread context classloader

Action:

Update your application's configuration

Thanks for any tips to solve this.

Upvotes: 14

Views: 99886

Answers (5)

Aish
Aish

Reputation: 1

Below dependency to POM should work.

<!-- https://mvnrepository.com/artifact/oracle/ojdbc6 -->
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>

Upvotes: 0

Ala Eddine Hmidi
Ala Eddine Hmidi

Reputation: 93

I have the same probleme Add this dependence to POM.xml file

<dependency>
            <groupId>com.oracle.ojdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <scope>runtime</scope>
    </dependency>

Upvotes: 1

ridvan.yazici
ridvan.yazici

Reputation: 79

Try on the project directory pom.xml file in in command promt or your ide.

mvn clean install

Upvotes: 0

Abdullah Imran
Abdullah Imran

Reputation: 399

    Add below dependency and repository in the pom

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

    <repositories>
        <repository>
            <id>codelds</id>
            <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
       </repositories>


Also add the following properties in the application.properties

 spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
    spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe(SID)
    spring.datasource.username=system
    spring.datasource.password=pw

Upvotes: 1

Damith
Damith

Reputation: 747

As its mentioned in your error the problem is with your configuration. Following line,

spring.datasource.driver.class-name=oracle.jdbc.driver.OracleDriver

should change as,

spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver

Note that its not driver.class-name, instead its driver-class-name

Upvotes: 12

Related Questions