postgresqljdbcpgbouncer

PostgresSQL: org.postgresql.util.PSQLException: ERROR: Unsupported startup parameter: search_path


When I try to connect to the database on postgres via jdbc, I get the following error: org.postgresql.util.PSQLException: ERROR: Unsupported startup parameter: search_path

This is how I create the connection:

val connection = DriverManager.getConnection(profile.connection + Option(profile.catalog).getOrElse("")+ "?currentSchema="+Option(profile.schema).getOrElse(""),
  profile.user, profile.password)

I use scala and a custom version of postgres.


Solution

  • pgbouncer

    In short, pgbouncer (at least my version) does not work with the search_path parameter. This discussion led me to the two following possible solutions:

    1. Change the pgbouncer config file by adding
      IGNORE_STARTUP_PARAMETERS: search_path
      
    2. Make a connection without using the currentSchema parameter in the connection string and create connection like this:
      val connection = 
        DriverManager.getConnection(
           profile.connection + Option(profile.catalog).getOrElse(""),
           profile.user, profile.password)
      
      Then, PostgreSQL will choose the scheme according to the rule set, in search_path. It usually is something like "$user", public. In this case, when connecting, it first tries to choose the same scheme as the user name, and if it does not find such a scheme, it chooses public.