Skip to content
Advertisement

Quarkus datasource with Heroku

I’m trying to deploy my Quarkus-app on Heroku. It works fine, but I needed to specify the datasource-parameters with fix values. Because Heroku might rotate this parameters, this is not a really good idea.

In Quarkus, I need this 3 parameters in application.properties:

quarkus.datasource.username
quarkus.datasource.password
quarkus.datasource.jdbc.url

Heroku only gives me 1 environment variable (DATABASE_URL), which defines a connection-string in the following manner: postgres://user:pass@server:port/db-name

I know I can use environment variables like so: quarkus.datasource.jdbc.url = jdbc:${DATABASE_URL}

But I need to split up the variable to extract user and password and to change prefix (postgresql instead of postgres).

Does anyone have an idea how to achieve this?

Advertisement

Answer

You can use the JDBC_DATABASE_URL, JDBC_DATABASE_USERNAME and JDBC_DATABASE_PASSWORD environment variables for your use-case.

For more details, you can find the documentation here: https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#using-the-jdbc_database_url

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement