Srikar balmuri
Srikar balmuri

Reputation: 11

Caused by: java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl

Unable to figure out what is causing the issue.

My application.properties file

    spring.datasource.url = "jdbc:mysql://localhost:3306/Medical_Tracking?useSSL=false"
    spring.datasource.username=root
    spring.datasource.password=root
    spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
    spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    spring.jpa.show-sql=true
    spring.jpa.hibernate.ddl-auto=update
    spring.jpa.generate-ddl=true

Quick help is appreciated

Upvotes: 1

Views: 9120

Answers (3)

Napolean
Napolean

Reputation: 5543

You may also get this error in case you are using wrong value for any of the datasource setting.

I was using driver class name in place of url

@Bean
@BatchDataSource
public DataSource batchDataSource() {
    return DataSourceBuilder.create().url(batchDbDriver)
            .driverClassName(batchDbDriver).username(batchDbUsername)
            .password(batchDbPassword)
            .build();
}



@Bean
@BatchDataSource
public DataSource batchDataSource() {
    return DataSourceBuilder.create().url(batchDbUrl)
            .driverClassName(batchDbDriver).username(batchDbUsername)
            .password(batchDbPassword)
            .build();
}

Upvotes: 0

mujx
mujx

Reputation: 61

Your config spring.datasource.url should not use double quotes (")

instead of:

spring.datasource.url = "jdbc:mysql://localhost:3306/Medical_Tracking?useSSL=false"

use:

spring.datasource.url = jdbc:mysql://localhost:3306/Medical_Tracking?useSSL=false

Upvotes: 6

Demobilizer
Demobilizer

Reputation: 748

Try following change in applications.properties file:

Replace

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

with

spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

Upvotes: -1

Related Questions