This section describes the steps you need to take before you can
- write or run programs that use the JDBC interface.
+ write or run programs that use the
JDBC> interface.
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.
- For details, refer to the
PostgreSQL> installation
- instructions. After installation, the driver should be found in
+ For details, refer to the
PostgreSQL>
+ installation instructions.
+ After installation, the driver should be found in
PREFIX>/share/java/postgresql.jar .
The resulting driver will be built for the version of Java you are
running. If you build with a 1.1
JDK> you will build a
- version that supports the JDBC 1 specification, if you build with
- a Java 2
JDK> (e.g., JDK> 1.2 or
-
JDK> 1.3) you will build a version that supports the
- JDBC 2 specification.
+ version that supports the
JDBC> 1 specification, 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
JDK you will build a version that supports the
To use the driver, the JAR archive (named
postgresql.jar if you built from source, otherwise
- it will likely be named jdbc&majorversion;-1.1.jar or
- jdbc&majorversion;-1.2.jar for the JDBC 1 and JDBC 2 versions
- respectively)
- needs to be included in the
- class path, either by putting it in the CLASSPATH
- environment variable, or by using flags on the
+ it will likely be named pg&majorversion;jdbc1.jar ,
+ pg&majorversion;jdbc2.jar , or
+
pg&majorversion;jdbc3.jar for the
JDBC> 1,
+
JDBC> 2, and JDBC> 3 versions respectively)
+ 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.
JDBC driver to access a database, and that
application is installed as
/usr/local/lib/myapp.jar . The PostgreSQL
- JDBC driver installed as
+
JDBC> driver installed as
/usr/local/pgsql/share/java/postgresql.jar>. To run
the application, we would use:
Also, the client authentication setup in the
pg_hba.conf file may need to be configured.
Refer to for details. The
-
JDBC driver supports the trust, ident,
- password, md5, and crypt authentication methods.
+
JDBC driver supports the
trust>,
+ ident>, password>, md5>, and
+ crypt> authentication methods.
Initializing the Driver
- This section describes how to load and initialize the JDBC driver
- in your programs.
+ This section describes how to load and initialize the
JDBC>
+ driver in your programs.
- The host name of the server. Defaults to localhost .
+ The host name of the server. Defaults to localhost . To specify an IPv6 address your must enclose the host parameter with square brackets, for example:
+jdbc:postgresql://[::1]:5740/accounting
+
-
- ResultSet is currently read only.
- You can not update data through the ResultSet .
- If you want to update data you need to do it the normal way
- by using the
SQL statement
UPDATE . This is
- in conformance with the
JDBC specification
- which does not require drivers to provide updatable result sets.
-
-
contains some examples on
- how to process binary data using the PostgreSQL JDBC driver.
+ how to process binary data using the PostgreSQL
JDBC> driver.
-
Processing Binary Data in JDBC
+
Processing Binary Data in JDBC>
For example, suppose you have a table containing the file names of
Connection Pools and Data Sources
- JDBC 2 introduced standard connection pooling features in an
- add-on
API known as the
JDBC 2.0 Optional
+
JDBC> 2 introduced standard connection pooling features in an
+ add-on
API> known as the
JDBC 2.0 Optional
Package (also known as the
JDBC 2.0
Standard Extension). These features have since been included in
- the core JDBC 3 API. The
PostgreSQL
-
JDBC drivers support these features if it has been compiled with
+ the core
JDBC> 3 API>. The
+
PostgreSQL JDBC drivers
+ support these features if it has been compiled with
JDK 1.3.x in combination with the
JDBC 2.0 Optional Package
(
JDBC 2), or with
JDK 1.4 or higher
Overview
- The
JDBC API provides a client
+ The
JDBC API> provides a client
and a server interface for connection pooling. The client
interface is javax.sql.DataSource ,
which is what application code will typically use to