0

How to connect to PostgreSQL using JDBC

Background

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

https://www.dropbox.com/s/p7pdlxp2xtvapg7/TurretaPostgresqlJDBC.zip?dl=0

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert