What is datasource.url and datasource.driverClassName in application.properties in Spring Boot

Viewed 941

I have some questions regarding the datasource in my application.properties

#Data Source properties
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/example
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

What exactly is the datasource.driver-class-name indicating?

2 Answers

This name refer to the classname of the JDBC driver for communicating with your database. This class will be loaded at launch time (it must be available in the classpath).

The url is the location of your database. Here you are saying my database is located at http://localhost:3306/example where example is the database name.

The DriverClassName is the name of the JDBC driver that you use to talk to your database. in case one of the Spring data libraries like JDBC or JPA is used you can omit that property.

Related