JDBC to Postgres with Schema Specification
Can you specify the database schema when connecting to Postgres using JDBC? If so, how?
Answer:
Yes, it is possible to specify the schema in JDBC when connecting to Postgres. Prior to JDBC v9.4, it was not possible to do this directly from the connection URL. However, with JDBC v9.4 and later, you can use the new currentSchema parameter in the connection URL, as shown below:
Previously, a popular workaround was to configure the schema in the connection URL using the searchpath parameter:
However, this approach is deprecated in favor of the new currentSchema parameter.
The above is the detailed content of Can You Specify the Database Schema in a JDBC Connection to Postgres?. For more information, please follow other related articles on the PHP Chinese website!