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 intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringConvert Java time zone to postgres time zone.private ISSPIClientcreateSSPI(PGStream pgStream, String spnServiceClass, boolean enableNegotiate) private booleanprivate voiddoAuthentication(PGStream pgStream, String host, String user, Properties info) private PGStreamenableGSSEncrypted(PGStream pgStream, GSSEncMode gssEncMode, String host, String user, Properties info, int connectTimeout) private PGStreamenableSSL(PGStream pgStream, SslMode sslMode, Properties info, int connectTimeout) getParametersForStartup(String user, String database, Properties info) private booleanisPrimary(QueryExecutor queryExecutor) private static voidopenConnectionImpl(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 voidrunInitialQueries(QueryExecutor queryExecutor, Properties info) private voidsendStartupPacket(PGStream pgStream, List<String[]> params) private PGStreamtryConnect(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:
SQLExceptionIOException
-
openConnectionImpl
public QueryExecutor openConnectionImpl(HostSpec[] hostSpecs, String user, String database, Properties info) throws SQLException Description copied from class:ConnectionFactoryImplementation 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:
openConnectionImplin 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
nullif 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.
-
credentialCacheExists
private boolean credentialCacheExists() -
enableGSSEncrypted
private PGStream enableGSSEncrypted(PGStream pgStream, GSSEncMode gssEncMode, String host, String user, Properties info, int connectTimeout) throws IOException, PSQLException - Throws:
IOExceptionPSQLException
-
enableSSL
private PGStream enableSSL(PGStream pgStream, SslMode sslMode, Properties info, int connectTimeout) throws IOException, PSQLException - Throws:
IOExceptionPSQLException
-
sendStartupPacket
- Throws:
IOException
-
doAuthentication
private void doAuthentication(PGStream pgStream, String host, String user, Properties info) throws IOException, SQLException - Throws:
IOExceptionSQLException
-
runInitialQueries
- Throws:
SQLException
-
isPrimary
- Throws:
SQLExceptionIOException
-