How to change DATABASE_URL for a heroku application

后端 未结 7 1762
醉话见心
醉话见心 2020-12-09 15:32

I wanted to use an external Database with my heroku application. But I\'m unable to edit the configuration cariables. I tried using GUI, Which says, Cannot overwrite attachm

7条回答
  •  無奈伤痛
    2020-12-09 15:52

    In my case, I needed to launch an java spring boot application with my personal data base (postgres). I have an instance on AWS, and when loading the app, an error was occurring because it would connect without ssl.

    Considering this documentation (https://devcenter.heroku.com/articles/connecting-to-relational-databases-on-heroku-with-java#using-ssl-with-postgresql), it says:

    We used to suggest adding the URL parameter sslmode=disable to JDBC URLs. We now require use of SSL for all new Heroku Postgres databases. We will be enforcing use of SSL on all Heroku Postgres databases from March 2018. Please do not disable SSL for your database or your applications may break.

    So, resuming, step 1, I deleted my addon Heroku Postgres on Resources tab. Step 2, I changed my application.yml from:

    datasource:
        driver-class-name: org.postgresql.Driver
        url: jdbc:postgresql://:/?createDatabaseIfNotExist=true&useSSL=false
        username: 
        password: 
    

    to

    datasource:
        driver-class-name: org.postgresql.Driver
        url: jdbc:postgresql://:/?createDatabaseIfNotExist=true&useSSL=false&sslmode=disable
        username: 
        password: 
    

    I added "&sslmode=disable" at the end of url string.

    And finally, rebuild/deploy (which in my case is automatic after pushing into my repo on github).

    I hope this would help someone.

    Peace...

提交回复
热议问题