1

I have a Postgres on a server which is available under https://somethig.my.domain/postgres on port 5432.

I'm trying to connect via DataGrip which uses a JDBC driver. But I cannot figure out the connection string.

Official docs doesn't have an example with a subpath:

  • jdbc:postgresql:database
  • jdbc:postgresql:/
  • jdbc:postgresql://host/database
  • jdbc:postgresql://host/
  • jdbc:postgresql://host:port/database
  • jdbc:postgresql://host:port/

And I cannot find a way for a subpath there.

Please note that at least 2 different ORMs for Node.js connect to the Postgres without any issue, so it's definitely possible. The question is how to form JDBC connection string. Nope, I'm just connecting to Docker containers here instead of reverse-proxied Postgres under a subpath. Please ignore.

9
  • What do you mean by "subpath"? Commented 23 hours ago
  • Per the Postgres JDBC docs you will need to percent encode the \ in the URL. Commented 22 hours ago
  • That is what I get for answering from my cell phone, it should be /. Commented 18 hours ago
  • Just forget the /postgres. There are no "subpaths" in DNS. Commented 14 hours ago
  • @RabbanKeyak the /postgres part of the URL. E.g. if a server is set up as a reverse proxy caddyserver.com/docs/caddyfile/patterns#reverse-proxy. Commented 6 hours ago

2 Answers 2

1

The DSN normally takes this shape on PostgreSQL:

postgres://postgres:[email protected]:5432/dummy

So you need to add jdbc: in the front like:

jdbc:postgres://postgres:[email protected]:5432/dummy

Sign up to request clarification or add additional context in comments.

1 Comment

Nope, I get an error: [99999] Unable to parse URL jdbc:postgresql://somethig.my.domain:5432/postgres/mydb
1

In a JDBC URL, the thing after the slash that you call “subpath” is the name of the database. Note that the protocol is not http, but jdbc:postgresql.

So to connect to the database postgres on host somethig.my.domain at the (default) port 5432, you would use the URL

jdbc:postgresql://somethig.my.domain:5432/postgres

Look at the image from the DataGrip documentation:

DataGrip connection information dialog

You can either enter the individual constituents (host, port, database name etc.) or you can override the URL that DataGrip constructs out of that information by entering your own JDBC URL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.