railwayapp-templates / postgres-ssl

MIT License
8 stars 25 forks source link

Unable to connect to the database from Java Spring application #8

Closed Gyrf921 closed 11 months ago

Gyrf921 commented 11 months ago

To use postgres and spring, you need to use jdbc:postgresql:/${PGHOST:localhost}:${PGPORT:5432}/${PGDATABASE:postgres} The recently submitted link is loaded from postgres://postgres:... Because of this (or because of other problems), try replacing the serum with the one you need for spring and connect to the subsequent setup

datasource:
    url: jdbc:postgresql:/${PGHOST:localhost}:${PGPORT:5432}/${PGDATABASE:postgres}
    password: ${PGPASSWORD:1234}
    username: ${PGUSER:postgres}
    driver-class-name: org.postgresql.Driver

it outputs the following information:

Failed to get a connection to the request metadata
java.lang.RuntimeException: The org.postgresql.Driver driver claims that it does not accept the jdbc Url, jdbc:postgresql:/viaduct.proxy.rlwy.net:43869/railway
coffee-cup commented 11 months ago

it looks like the jdbc Postgres URL is missing a /. I think it should be

jdbc:postgresql://${PGHOST:localhost}:${PGPORT:5432}/${PGDATABASE:postgres}

instead (not the additional / after postgresql)

Gyrf921 commented 11 months ago

Thank you very much, it helped!!!