Package org.postgresql.core.v3
Class ConnectionFactoryImpl
java.lang.Object
org.postgresql.core.ConnectionFactory
org.postgresql.core.v3.ConnectionFactoryImpl
ConnectionFactory implementation for version 3 (7.4+) connections.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final Logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
Convert Java time zone to postgres time zone.private ISSPIClient
createSSPI
(PGStream pgStream, String spnServiceClass, boolean enableNegotiate) private void
doAuthentication
(PGStream pgStream, String host, String user, Properties info) private PGStream
enableGSSEncrypted
(PGStream pgStream, GSSEncMode gssEncMode, String host, String user, Properties info, int connectTimeout) private PGStream
enableSSL
(PGStream pgStream, SslMode sslMode, Properties info, int connectTimeout) getParametersForStartup
(String user, String database, Properties info) private boolean
isPrimary
(QueryExecutor queryExecutor) private static void
openConnectionImpl
(HostSpec[] hostSpecs, String user, String database, Properties info) Implementation ofConnectionFactory.openConnection(org.postgresql.util.HostSpec[], java.lang.String, java.lang.String, java.util.Properties)
for a particular protocol version.private void
runInitialQueries
(QueryExecutor queryExecutor, Properties info) private void
sendStartupPacket
(PGStream pgStream, List<String[]> params) private PGStream
tryConnect
(String user, String database, Properties info, SocketFactory socketFactory, HostSpec hostSpec, SslMode sslMode, GSSEncMode gssEncMode) Methods inherited from class org.postgresql.core.ConnectionFactory
closeStream, openConnection
-
Field Details
-
LOGGER
-
AUTH_REQ_OK
private static final int AUTH_REQ_OK- See Also:
-
AUTH_REQ_KRB4
private static final int AUTH_REQ_KRB4- See Also:
-
AUTH_REQ_KRB5
private static final int AUTH_REQ_KRB5- See Also:
-
AUTH_REQ_PASSWORD
private static final int AUTH_REQ_PASSWORD- See Also:
-
AUTH_REQ_CRYPT
private static final int AUTH_REQ_CRYPT- See Also:
-
AUTH_REQ_MD5
private static final int AUTH_REQ_MD5- See Also:
-
AUTH_REQ_SCM
private static final int AUTH_REQ_SCM- See Also:
-
AUTH_REQ_GSS
private static final int AUTH_REQ_GSS- See Also:
-
AUTH_REQ_GSS_CONTINUE
private static final int AUTH_REQ_GSS_CONTINUE- See Also:
-
AUTH_REQ_SSPI
private static final int AUTH_REQ_SSPI- See Also:
-
AUTH_REQ_SASL
private static final int AUTH_REQ_SASL- See Also:
-
AUTH_REQ_SASL_CONTINUE
private static final int AUTH_REQ_SASL_CONTINUE- See Also:
-
AUTH_REQ_SASL_FINAL
private static final int AUTH_REQ_SASL_FINAL- See Also:
-
-
Constructor Details
-
ConnectionFactoryImpl
public ConnectionFactoryImpl()
-
-
Method Details
-
createSSPI
-
tryConnect
private PGStream tryConnect(String user, String database, Properties info, SocketFactory socketFactory, HostSpec hostSpec, SslMode sslMode, GSSEncMode gssEncMode) throws SQLException, IOException - Throws:
SQLException
IOException
-
openConnectionImpl
public QueryExecutor openConnectionImpl(HostSpec[] hostSpecs, String user, String database, Properties info) throws SQLException Description copied from class:ConnectionFactory
Implementation ofConnectionFactory.openConnection(org.postgresql.util.HostSpec[], java.lang.String, java.lang.String, java.util.Properties)
for a particular protocol version. Implemented by subclasses ofConnectionFactory
.- Specified by:
openConnectionImpl
in classConnectionFactory
- Parameters:
hostSpecs
- at least one host and port to connect to; multiple elements for round-robin failoveruser
- the username to authenticate with; may not be null.database
- the database on the server to connect to; may not be null.info
- extra properties controlling the connection; notably, "password" if present supplies the password to authenticate with.- Returns:
- the new, initialized, connection, or
null
if this protocol version is not supported by the server. - Throws:
SQLException
- if the connection could not be established for a reason other than protocol version incompatibility.
-
getParametersForStartup
-
log
-
createPostgresTimeZone
Convert Java time zone to postgres time zone. All others stay the same except that GMT+nn changes to GMT-nn and vise versa.- Returns:
- The current JVM time zone in postgresql format.
-
enableGSSEncrypted
private PGStream enableGSSEncrypted(PGStream pgStream, GSSEncMode gssEncMode, String host, String user, Properties info, int connectTimeout) throws IOException, PSQLException - Throws:
IOException
PSQLException
-
enableSSL
private PGStream enableSSL(PGStream pgStream, SslMode sslMode, Properties info, int connectTimeout) throws IOException, PSQLException - Throws:
IOException
PSQLException
-
sendStartupPacket
- Throws:
IOException
-
doAuthentication
private void doAuthentication(PGStream pgStream, String host, String user, Properties info) throws IOException, SQLException - Throws:
IOException
SQLException
-
runInitialQueries
- Throws:
SQLException
-
isPrimary
- Throws:
SQLException
IOException
-