Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 631
Ethan Wan Avatar asked Oct 24 '25 17:10

Ethan Wan


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

like image 67
Mickaël B. Avatar answered Oct 27 '25 05:10

Mickaël B.


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.

like image 41
Daniel Jacob Avatar answered Oct 27 '25 06:10

Daniel Jacob