How to connect to PostgreSQL using JDBC


This article demonstrates how to connect to Postgres using JDBC.

Software Environment

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

Maven dependency

Create a Maven Project

To create a Maven project, follow the steps on this post How to create Maven project in Eclipse. Just specify “jar” for packaging as we do not need to deploy this on a web container. Configure the pom.xml file to add the dependency for the PostgreSQL JDBC driver (see Software Environment above).

The Codes

Download the Project


Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert