krenkz
krenkz

Reputation: 470

Creating a Postgres database with JDBC Driver when starting a SpringBoot app?

When I want to use a Mysql database in a Springboot app, I am able to create it on start via a string in properties similar to this:

spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/testDb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true

Nevertheless PostgreSQL seems to ignore this:

spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/testdb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true

Is there a way to create a PostgreSQL db on start of a SpringBoot app before Flyway attempts to initiate tables?

Upvotes: 1

Views: 927

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116051

Postgres doesn't support creating a database on demand via the JDBC URL. You can learn about what configuration is possible in the documentation.

Upvotes: 2

Related Questions