This page in other versions: Unsupported versions: 6.4 / 6.5 / 7.0

Chapter 56. JDBC Interface

Author: Written by Peter T. Mount, the author of the JDBC driver.

JDBC is a core API of Java 1.1 and later. It provides a standard set of interfaces to SQL-compliant databases.

Postgres provides a type 4 JDBC Driver. Type 4 indicates that the driver is written in Pure Java, and communicates in the database's own network protocol. Because of this, the driver is platform independent. Once compiled, the driver can be used on any platform.

Building the JDBC Interface

Compiling the Driver

The driver's source is located in the src/interfaces/jdbc directory of the source tree. To compile simply change directory to that directory, and type:

% make

Upon completion, you will find the archive postgresql.jar in the current directory. This is the JDBC driver.

Note: You must use make, not javac, as the driver uses some dynamic loading techniques for performance reasons, and javac cannot cope. The Makefile will generate the jar archive.

Installing the Driver

To use the driver, the jar archive postgresql.jar needs to be included in the CLASSPATH.


I have an application that uses the JDBC driver to access a large database containing astronomical objects. I have the application and the jdbc driver installed in the /usr/local/lib directory, and the java jdk installed in /usr/local/jdk1.1.6.

To run the application, I would use:

export CLASSPATH = \ /usr/local/lib/finder.jar:/usr/local/lib/postgresql.jar:. java

Loading the driver is covered later on in this chapter.

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group