Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (6.1k points)

spring.freemarker.cache:false

spring.datasource.url=jdbc:mysql://localhost/mydb

spring.datasource.username=user

spring.datasource.password=pass

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

I am getting this following error even with the driver-class-name defined already.

java.lang.IllegalStateException: Cannot load driver class: com.mysql.jdbc.Driver at org.springframework.util.Assert.state(Assert.java:392) ~[spring-core-4.2.1.RELEASE.jar:4.2.1.RELEASE] at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:153) ~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:119) ~[spring-boot-autoconfigure-1.3.0.M5.jar:1.3.0.M5] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60] at ......

 and it goes on.

1 Answer

0 votes
by (12.7k points)

If you are working with Maven, add these to your pom.xml:

For MySQL 5.6, 5.7, 8.x and Java >= 8 use the following;

<dependency>

    <groupId>mysql</groupId>

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

    <version>8.0.18</version>

</dependency>

For MySQL <= 5.5 or Java <= 7 or JDBC < 4.2 use the following;

<dependency>

    <groupId>mysql</groupId>

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

    <version>5.1.48</version>

</dependency>

 Want to know more about SQL ? Join this SQL Certification by Intellipaat now.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...