|
|
To use the driver, the JAR archive (named
postgresql.jar
if you built from source, otherwise
it will likely be named with the following convention:
postgresql-
,
for example [server version]
.[buildnumber]
.jdbc[JDBC version]
.jarpostgresql-8.0-310.jdbc3.jar
)
needs to be included in the class path, either by putting it in the
CLASSPATH
environment variable, or by using flags on the
java command line.
For instance, assume we have an application that uses the
JDBC driver to access a database, and that
application is installed as
/usr/local/lib/myapp.jar
. The
PostgreSQL™ JDBC driver installed as
/usr/share/postgresql/postgresql.jar
. To run
the application, we would use:
export CLASSPATH=/usr/local/lib/myapp.jar:/usr/share/postgresql/postgresql.jar:. java MyApp
Loading the driver from within the application is covered in Chapter 3, Initializing the Driver.