From 8d108715312517797fcf4e3650eb983b0c9a7b6d Mon Sep 17 00:00:00 2001 From: Taylor Becker Date: Fri, 1 Mar 2024 11:02:07 -0500 Subject: [PATCH] Move db URL params such that the database engine is set statically, not in the URL (#2) Enforces the jdbc:engine rather than letting anything be specified in the environment variable. This also helps prevent errors if one were to provided EG a postgres jdbc connection string in the MYSQL_URL variable as the application runs some bootstrapping scripts depending on the database value. --- src/main/resources/application-mysql.properties | 2 +- src/main/resources/application-postgres.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application-mysql.properties b/src/main/resources/application-mysql.properties index e23dfa605..7a1ac733c 100644 --- a/src/main/resources/application-mysql.properties +++ b/src/main/resources/application-mysql.properties @@ -1,6 +1,6 @@ # database init, supports mysql too database=mysql -spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost/petclinic} +spring.datasource.url=jdbc:mysql://${MYSQL_URL:localhost/petclinic} spring.datasource.username=${MYSQL_USER:petclinic} spring.datasource.password=${MYSQL_PASS:petclinic} # SQL is written to be idempotent so this is safe diff --git a/src/main/resources/application-postgres.properties b/src/main/resources/application-postgres.properties index 60889b43c..333ce5f0a 100644 --- a/src/main/resources/application-postgres.properties +++ b/src/main/resources/application-postgres.properties @@ -1,5 +1,5 @@ database=postgres -spring.datasource.url=${POSTGRES_URL:jdbc:postgresql://localhost/petclinic} +spring.datasource.url=jdbc:postgresql://${POSTGRES_URL:localhost/petclinic} spring.datasource.username=${POSTGRES_USER:petclinic} spring.datasource.password=${POSTGRES_PASS:petclinic} # SQL is written to be idempotent so this is safe