Top Description Fields Constructors Methods
org.postgresql.core

public abstract Class ConnectionFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.postgresql.core.v3.ConnectionFactoryImpl
Imports
org.postgresql.PGProperty, org.postgresql.core.v3.ConnectionFactoryImpl, org.postgresql.util.GT, .HostSpec, .PSQLException, .PSQLState, org.checkerframework.checker.nullness.qual.Nullable, java.io.IOException, java.sql.SQLException, java.util.Properties, java.util.logging.Level, .Logger

Handles protocol-specific connection setup.
Author
Oliver Jowett ([email protected])

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
closeStream(@Nullable PGStream
The stream to close.
newStream
)

Safely close the given stream.

public static QueryExecutor

Returns:

the new, initialized, connection
openConnection
(HostSpec[]
at least one host and port to connect to; multiple elements for round-robin failover
hostSpecs
,
Properties
extra properties controlling the connection; notably, "password" if present supplies the password to authenticate with.
info
)

Establishes and initializes a new connection.

public abstract QueryExecutor

Returns:

the new, initialized, connection, or null if this protocol version is not supported by the server.
openConnectionImpl
(HostSpec[]
at least one host and port to connect to; multiple elements for round-robin failover
hostSpecs
,
Properties
extra properties controlling the connection; notably, "password" if present supplies the password to authenticate with.
info
)

Implementation of openConnection for a particular protocol version.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

ConnectionFactoryback to summary
public ConnectionFactory()

Method Detail

closeStreamback to summary
protected void closeStream(@Nullable PGStream newStream)

Safely close the given stream.

Parameters
newStream:@Nullable PGStream

The stream to close.

openConnectionback to summary
public static QueryExecutor openConnection(HostSpec[] hostSpecs, Properties info) throws SQLException

Establishes and initializes a new connection.

If the "protocolVersion" property is specified, only that protocol version is tried. Otherwise, all protocols are tried in order, falling back to older protocols as necessary.

Currently, protocol versions 3 (7.4+) is supported.

Parameters
hostSpecs:HostSpec[]

at least one host and port to connect to; multiple elements for round-robin failover

info:Properties

extra properties controlling the connection; notably, "password" if present supplies the password to authenticate with.

Returns:QueryExecutor

the new, initialized, connection

Exceptions
SQLException:
if the connection could not be established.
openConnectionImplback to summary
public abstract QueryExecutor openConnectionImpl(HostSpec[] hostSpecs, Properties info) throws SQLException

Implementation of openConnection for a particular protocol version. Implemented by subclasses of ConnectionFactory.

Parameters
hostSpecs:HostSpec[]

at least one host and port to connect to; multiple elements for round-robin failover

info:Properties

extra properties controlling the connection; notably, "password" if present supplies the password to authenticate with.

Returns:QueryExecutor

the new, initialized, connection, or null if this protocol version is not supported by the server.

Exceptions
SQLException:
if the connection could not be established for a reason other than protocol version incompatibility.