javascalajdbcdoobie

How to set port number in doobie database url?


My Postgresql-server is running on port 6000 (not the default port 5432). How can I set put this port number into doobie jdbc url?

val xa = Transactor.fromDriverManager[IO](
  "org.postgresql.Driver",     // driver classname
  "jdbc:postgresql:databasename",     // connect URL (driver-specific)
  "user",                  // user
  "password"                           // password

This is the error message:

[info] - should success *** FAILED ***
[info]   org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Solution

  • The port is part of the connection url:

    val xa = Transactor.fromDriverManager[IO](
      "org.postgresql.Driver",     // driver classname
      "jdbc:postgresql://localhost:5432/world",     // connect URL (driver-specific)
      "user",                  // user
      "password"                           // password