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

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

Asked on January 7, 2019 in PostgreSQL.
Add Comment


  • 3 Answer(s)

    Postgresql  version 9.4, you can use the currentSchema parameter in your connection string.

    Like this

    jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema
    
    
    Answered on January 7, 2019.
    Add Comment

    It’s work to your current environment.you could also set the user’s default schema to your desired schema:

    ALTER USER user_name SET search_path to 'schema'
    
    
    Answered on January 7, 2019.
    Add Comment

    ALTER USER user_name SET search_path to ‘schema’

    Answered on March 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.