marcosbeirigo marcosbeirigo - 7 days ago 6
Java Question

Is it possible to specify schema when connecting to postgres with JDBC?

Is it possible? Can i specify it on the connection URL? How to do that?

Answer

I know this was answered already, but I just ran into the same issue trying to specify the schema to use for the liquibase command line.

According to this: http://web.archive.org/web/20141025044151/http://postgresql.1045698.n5.nabble.com/Patch-to-allow-setting-schema-search-path-in-the-connectionURL-td2174512.html

You can specify the url like so:

jdbc:postgresql://localhost:5432/mydatabase?searchpath=myschema

Update As of 9.4 you can specify the url with the new currentSchema parameter like so:

jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema
Comments