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

6.2k Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

pgbauncer

In short, pgbouncer at least my version does not work with the search_path parameter, this discussion led me to this idea. There are two ways to fix this problem:

  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 he will choose the scheme according to the rule set, in search_path, they usually set something like "$user", public, in this case, when connecting, he first tries to choose the same scheme as the user name, and if he does not find such a scheme, he chooses public.