Search code examples
javaspringspring-bootbackendmysql-connector

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


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?


Solution

  • 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.