A database URL is a connection string that identifies a database and tells a client how to connect. In Spring Boot, it is commonly supplied through configuration properties rather than an explicitly declared DataSource bean. section 6.1.2
A database URL works with related connection settings:
- Spring Boot can infer the JDBC driver class from the URL structure when the driver is available. section 6.1.2
- Username and password properties provide credentials alongside the URL. section 6.1.2
- The configured values support automatic DataSource creation and connection-pool setup. section 6.1.2
An H2 database URL
Setting the H2 database name to tacocloud produces the JDBC URL jdbc:h2:mem:tacocloud, which can be entered in the H2 console connection settings. section 3.1.2
spring:
datasource:
url: jdbc:mysql:/ /localhost/tacocloud
username: tacouser
password: tacopassword
Use this YAML configuration to connect Spring Boot to a MySQL database with a URL, username, and password. section 6.1.2
