Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource: Property: driverclassname Value: oracle.jdbc.OracleDriver Origin: "driverClassName" from property source "source" Reason: Unable to set value for property driver-class-name Action: Update your application's configuration

This is same issue I have but i am not using maven.

I am using spring Boot 2.0.0 with following starters.

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
    testCompile "org.springframework.boot:spring-boot-starter-test"

And this is my application.properties file

spring.datasource.url= *****
spring.datasource.username= ******
spring.datasource.password= ******

Look up application.properties file.

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

Full code.

spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=upate
spring.datasource.url=jdbc:mysql://localhost:3306/database_name
spring.datasource.username=admin
spring.datasource.password=admin1234

As Stephane Nicoll said, you don't have driver on your classpath. You need to include jdbc driver on your gradle build as below. However, you don't have to stick to driver version that I have included.

dependencies {
    compile "org.springframework.boot:spring-boot-starter-web"
    compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1"
    testCompile "org.springframework.boot:spring-boot-starter-test"
    runtime('com.oracle:ojdbc7:12.1.0.2.0') 
                Since you've verified this question, I can only assume that was your problem. Since you haven't created an issue as I've asked in my answer, I've created one myself
– Stephane Nicoll
                May 9, 2018 at 15:13
                Thanks so much for pointing this out. Had the same issue with maven - single JUnit tests did not run but the maven build did. The solution was to add the compile scope to the database connector (in memory db in my case).
– CrimsonMike
                Oct 28, 2020 at 20:54
                From Spring Boot 2.1.0 the default driver name for mysql connections is com.mysql.cj.jdbc.Driver: github.com/spring-projects/spring-boot/issues/13688. commit: 18904ec29138080dcfc707b6150dc0069b7a0ac4.  If it's possible to update the mysql connector with with one compatible (driverName= com.mysql.cj.jdbc.Driver), that would be a good option.   If not, this one is good workaround
– chindo
                Sep 15, 2020 at 15:21

I have added the below in properties file

spring.datasource.driverclassname = com.mysql.jdbc.Driver hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

and added the below in POM file

        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>

It is working fine now.

@Bibin Worked for me as i was using mySQL, But now i am getting another exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. – Aakash Patel Jan 31, 2019 at 17:00

We have to add the dependency and have to remove property "spring.datasource.driver-class-name"

 <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency> 
                I am still facing this issue, though when running my app it will use the default profile. So it shouldn't matter right? No solution seems to work though.
– J-me
                Nov 17, 2019 at 19:40
                I don't have any profile set, so when i the app it Will say: no profile found, switched to profile default. Profiles are things a developer Just maken op right, so I was wondering why it would even matter.
– J-me
                Nov 20, 2019 at 8:16

If youre running intelliJ and run into this issue just add this dependency in your pom.xml file:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>

This happened to me as well. But after adding the correct MySQL version in my pom.xml, and explicitly adding the driver details to application.properties resolved the issue.

  • Application.properties

    spring.datasource.driver-class-name=com.mysql.jdbc.Driver

  • pom.xml

     <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <version>5.1.34</version>
     </dependency>
    

    Add the MySQL version to pom.xml as per the version installed.

    Check your pom.xml if you dont have the mysql dependency, can add like this

    <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
    </dependency>
    

    Befor of update the file, run maven

    mvn clean install
    

    to update your maven's dependencies

    I had the same error, the mistake was in pom.xml file. I had a mistake in my SQL connector dependency. If its okay in your case check also application.properties file you may not include driver

    spring.datasource.url=jdbc:mysql://localhost:3307/test?useSSL=false
    spring.datasource.username=root
    spring.datasource.password=root
    spring.jpa.show-sql=true
    spring.jpa.generate-ddl=false
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
    spring.mvc.view.prefix = /WEB-INF/jsp/
    spring.mvc.view.suffix = .jsp
    

    All of these answers require code changes, and in my situation the code wasn't the problem. The error would occur randomly in my development environment, seamingly for no reason, not associated with any config or code change that I'd made.

    I think I've found a consistent way to fix it, but I'm not sure why it works.

  • Shut down InteliJ IDEA
  • Delete ".idea" and "build" folders
  • Restart IDEA
  • This seems to resolve it, but the random nature of this really bothers me. I don't know why it occurs, or why the above fixes it.

    I'm just adding this in case it helps others.

    Add or modify the application.properties file.

        spring.datasource.driver-class-name=com.mysql.jdbc.Driver
        spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    

    Older version used:

    spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
    

    This does NOT work anymore; hence, the change to spring.jpa.properties.hibernate.dialect.

    Resulting in the following:

    spring.datasource.url=jdbc:mysql://localhost:3306/<db name>
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    spring.datasource.username=<db username>
    spring.datasource.password=<db password>
    spring.jpa.hibernate.ddl-auto=validate
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    spring.jpa.database=mysql
    spring.jpa.show-sql=true
    

    Clean the build artifacts from previous builds

    mvn clean install
    

    An for IntelliJ, invalidate the cache and restart.
    File --> Invalidate Caches...

    Run the project.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •