Postgresql Driver Url
With JDBC, a database is represented by a
URL Uniform Resource Locator. With
PostgreSQL, this takes one of the
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database
The parameters have the following meanings:
The host name of the server. Defaults to localhost.
To specify an IPv6 address your must enclose the
with square brackets, for example:
jdbc:postgresql:// ::1 :5740/accounting
The port number the server is listening on. Defaults to the
PostgreSQL standard port number 5432.
To connect, you need to get a Connection instance from
you use the DriverManager.getConnection method:
Connection db DriverManager.getConnection url, username, password ;
In addition to the standard connection parameters the driver supports a
number of additional properties which can be used to specify additional
driver behavior specific to PostgreSQL. These
properties may be specified in either the connection
Properties object parameter to
DriverManager.getConnection. The following
examples illustrate the use of both methods to establish a SSL
String url jdbc:postgresql://localhost/test ;
Properties props new Properties ;
props.setProperty user, fred ;
props.setProperty password, secret ;
Connection conn DriverManager.getConnection url, props ;
String url jdbc:postgresql://localhost/test.user fred password secret ssl true ;
Connection conn DriverManager.getConnection url ;
The database user on whose behalf the connection is being made.
Connect using SSL. The driver must have been
compiled with SSL support. This property does
not need a value associated with it. The mere presence of it
specifies a SSL connection. However, for
compatibility with future versions, the value true is
preferred. For more information see Chapter 4, Using SSL.
The provided value is a class name to use as the
SSLSocketFactory when establishing a
For more information see the section called Custom SSLSocketFactory.
This value is an optional argument to the constructor of the
sslfactory class provided above.
Act like an older version of the driver to retain compatibility with
older applications. At the moment this controls two driver behaviors,
the connection protocol and the handling of binary data fields.
Older versions of the driver used this property to also control the
protocol used to connect to the backend. This is now controlled by the
Information on binary data handling is detailed in
Chapter 7, Storing Binary Data. To force the use of
Large Objects set the compatible property to 7.1.
The driver supports both the V2 and V3 frontend/backend protocols.
The V3 protocol was introduced in 7.4 and the driver will by default
try to connect using the V3 protocol, if that fails it will fall
back to the V2 protocol. If the protocolVersion property is
specified, the driver will try only the specified protocol which
should be either 2 or 3. Setting protocolVersion to 2 may
be used to avoid the failed attempt to use the V3 protocol when
connecting to a version 7.3 or earlier server, or to force the
driver to use the V2 protocol despite connecting to a 7.4 or greater
Set the amount of logging information printed to the DriverManager s
current value for LogStream or LogWriter. It currently supports
values of org.postgresql.Driver.DEBUG 2 and
INFO will log very little information while
DEBUG will produce significant detail. This
property is only really useful if you are a developer or are
having problems with the driver.
The character set to use for data sent to the database or recieved
from the database. This property is only relevent for server
versions less than or equal to 7.2. The 7.3 release was the first
with multibyte support compiled by default and the driver uses
its character set translation facilities instead of trying to do
When using the V3 protocol the driver monitors changes in certain
server configuration parameters that should not be touched by
end users. The client_encoding setting is set
by the driver and should not be altered. If the driver detects
a change it will abort the connection. There is one legitimate
exception to this behavior though, using the COPY
command on a file residing on the server s filesystem. The only
means of specifying the encoding of this file is by altering the
JDBC team considers this a failing of the
COPY command and hopes to provide an alternate
means of specifying the encoding in the future, but for now there
is this URL parameter. Enable this only if
you need to override the client encoding when doing a copy.
Determine the number of PreparedStatement
executions required before switching over to use server side prepared
statements. The default is five, meaning start using server side
prepared statements on the fifth execution of the same
PreparedStatement object. More
information on server side prepared
statements is available in the section called Server Prepared Statements.
The postgresql SDBC Driver allows to use the postgresql database from OpenOffice.org how the url must look like to access the postgresql driver.
PostgreSQL Driver Configuration Properties. URL Connection String. jdbc:postgresql://server-name:server-port/database-name. Note – NOTE: Default.
Listed below are connection examples for PostgreSQL:
DRIVER CLASS: org.postgresql.Driver
DRIVER LOCATION: Simply provide the location of the jar file containing the PostgreSQL JDBC Drivers. These
drivers can be obtained from PostgreSQL. See the PostgreSQL web site for more information.
JDBC URL FORMAT: jdbc:postgresql://:/
The default port for PostgreSQL is 5432. Usually, if the default port is being used
by the database server, the : value of the JDBC url can be omitted.
jdbc:postgresql://neptune.acme.com:5432/test
jdbc:postgresql://127.0.0.32/test.
- With JDBC, a database is represented by a URL Uniform Resource Locator. With PostgreSQL , this takes one of the following forms.
- DRIVER CLASS: org.postgresql.Driver DRIVER LOCATION: Simply provide the location of the jar file containing the PostgreSQL JDBC Drivers. These drivers can be.
- Initializing the Driver. With JDBC, a database is represented by a URL Uniform Resource Locator. With PostgreSQL, this takes one of the following forms.
- File Browser; File Browser Top odbc versions msi Directories About PostgreSQL Copyright 1996-2016 The PostgreSQL Global Development Group.
PostgreSQL JDBC Driver and URL Information
Connecting to the Database