File: classpath.md

package info (click to toggle)
libpgjava 42.2.5-2%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,136 kB
  • sloc: java: 57,821; xml: 1,135; sh: 307; perl: 99; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
layout: default_docs
title: Setting up the Class Path
header: Chapter 2. Setting up the JDBC Driver
resource: media
previoustitle: Chapter 2. Setting up the JDBC Driver
previous: setup.html
nexttitle: Preparing the Database Server for JDBC
next: prepare.html
---

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-*[server version]*.*[build number]*.jdbc*[JDBC version]*.jar`,
for example `postgresql-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/local/pgsql/share/java/postgresql.jar`.
To run the application, we would use:

```bash
export CLASSPATH=/usr/local/lib/myapp.jar:/usr/local/pgsql/share/java/postgresql.jar:.
java MyApp
```

Loading the driver from within the application is covered in [Chapter 3, Initializing the Driver](use.html).