Postgres.app

The easiest way to get started with PostgreSQL on the Mac

Java

JDBC

PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setDatabaseName(YOUR_DATABASE_NAME);

The easiest way to get the PostgreSQL JDBC driver is using Maven.

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>9.4.1207</version>
</dependency>

Make sure the JDBC version of the driver matches your Java version.

Java VersionJDBC Version
Java 1.6JDBC 4.0
Java 1.7JDBC 4.1
Java 1.8JDBC 4.2

For more information check out the Connecting to the Database chapter of the official documentation.