Chapter 2. Setting up the JDBC Driver

Table of Contents

Getting the Driver
Setting up the Class Path
Preparing the Database Server for JDBC
Creating a Database

This section describes the steps you need to take before you can write or run programs that use the JDBC interface.

Precompiled versions of the driver can be downloaded from the PostgreSQLJDBC web site.

Alternatively you can build the driver from source, but you should only need to do this if you are making changes to the source code. To build the JDBC driver, you need Ant 1.5 or higher and a JDK. Ant is a special tool for building Java-based packages. It can be downloaded from the Ant web site.

If you have several Java compilers installed, it depends on the Ant configuration which one gets used. Precompiled Ant distributions are typically set up to read a file .antrc in the current user's home directory for configuration. For example, to use a different JDK than the default, this may work:


To compile the driver simply run ant in the top level directory. The compiled driver will be placed in jars/postgresql.jar. The resulting driver will be built for the version of Java you are running. If you build with a 1.2 or 1.3 JDK you will build a version that supports the JDBC 2 specification, and finally if you build with a 1.4 or 5.0 JDK you will build a version that supports the JDBC 3 specification.