0

How to specify a default schema when connecting to PostgreSQL using JDBC

Background

PostgreSQL is a better choice than MySQL. Not only that, I have a client who has plans to migrate from Oracle 11g to PostgreSQL. Now imagine that! One of things you need to know when working with PostgreSQL is how to set a default schema when connecting to it.

This article demonstrates how to achieve just that.

Software Environment

  • Windows 7 Professional SP1
  • PostgreSQL 9.4 for Windows
  • PostgreSQL JDBC Driver 9.3-1102-jdbc41

Maven Dependency

JPA, JDBC, and etc

To specify a default schema upon connecting to PostgreSQL, use currentSchema parameter to the JDBC URL.

postgresql-default-schema33