Class StandardSocketFactory
java.lang.Object
com.mysql.jdbc.StandardSocketFactory
- All Implemented Interfaces:
SocketFactory, SocketMetadata
- Direct Known Subclasses:
SocksProxySocketFactory
Socket factory for vanilla TCP/IP sockets (the standard)
-
Nested Class Summary
Nested classes/interfaces inherited from interface SocketMetadata
SocketMetadata.Helper -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe hostname to connect toprotected longTime when last Login Timeout check occurredprotected intThe remaining login time in milliseconds.protected intThe port number to connect toprotected SocketThe underlying TCP/IP socket to useprotected intBackup original Socket timeout to be restored after handshakestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCalled by the driver after issuing the MySQL protocol handshake and reading the results of the handshake.Called by the driver before issuing the MySQL protocol handshake.connect(String hostname, int portNumber, Properties props) Creates a new socket using the given properties.protected SocketcreateSocket(Properties props) Create the raw socket.protected intgetRealTimeout(int expectedTimeout) Validates the connection/socket timeout that must really be used.booleanprotected voidDecrements elapsed time since last reset from login timeout count down.
-
Field Details
-
TCP_NO_DELAY_PROPERTY_NAME
- See Also:
-
TCP_KEEP_ALIVE_DEFAULT_VALUE
- See Also:
-
TCP_KEEP_ALIVE_PROPERTY_NAME
- See Also:
-
TCP_RCV_BUF_PROPERTY_NAME
- See Also:
-
TCP_SND_BUF_PROPERTY_NAME
- See Also:
-
TCP_TRAFFIC_CLASS_PROPERTY_NAME
- See Also:
-
TCP_RCV_BUF_DEFAULT_VALUE
- See Also:
-
TCP_SND_BUF_DEFAULT_VALUE
- See Also:
-
TCP_TRAFFIC_CLASS_DEFAULT_VALUE
- See Also:
-
TCP_NO_DELAY_DEFAULT_VALUE
- See Also:
-
host
The hostname to connect to -
port
protected int portThe port number to connect to -
rawSocket
The underlying TCP/IP socket to use -
loginTimeoutCountdown
protected int loginTimeoutCountdownThe remaining login time in milliseconds. Initial value set from defined DriverManager.setLoginTimeout() -
loginTimeoutCheckTimestamp
protected long loginTimeoutCheckTimestampTime when last Login Timeout check occurred -
socketTimeoutBackup
protected int socketTimeoutBackupBackup original Socket timeout to be restored after handshake
-
-
Constructor Details
-
StandardSocketFactory
public StandardSocketFactory()
-
-
Method Details
-
afterHandshake
Called by the driver after issuing the MySQL protocol handshake and reading the results of the handshake.- Specified by:
afterHandshakein interfaceSocketFactory- Returns:
- The socket to use after the handshake
- Throws:
SocketException- if a socket error occursIOException- if an I/O error occurs
-
beforeHandshake
Called by the driver before issuing the MySQL protocol handshake. Should return the socket instance that should be used during the handshake.- Specified by:
beforeHandshakein interfaceSocketFactory- Returns:
- the socket to use before the handshake
- Throws:
SocketException- if a socket error occursIOException- if an I/O error occurs
-
createSocket
Create the raw socket.- Parameters:
props- properties available to affect behavior during socket creation.
-
connect
public Socket connect(String hostname, int portNumber, Properties props) throws SocketException, IOException Description copied from interface:SocketFactoryCreates a new socket using the given properties. Properties are parsed by the driver from the URL. All properties other than sensitive ones (user and password) are passed to this method. The driver will instantiate the socket factory with the class name given in the property "socketFactory", where the standard iscom.mysql.jdbc.StandardSocketFactoryImplementing classes are responsible for handling synchronization of this method (if needed).- Specified by:
connectin interfaceSocketFactory- Parameters:
hostname- the hostname passed in the JDBC URL. It will be a single hostname, as the driver parses multi-hosts (for failover) and calls this method for each host connection attempt.portNumber- the port number to connect to (if required).props- properties passed to the driver via the URL and/or properties instance.- Returns:
- a socket connected to the given host
- Throws:
SocketException- if a socket error occursIOException- if an I/O error occurs- See Also:
-
isLocallyConnected
- Specified by:
isLocallyConnectedin interfaceSocketMetadata- Throws:
SQLException
-
resetLoginTimeCountdown
Decrements elapsed time since last reset from login timeout count down.- Throws:
SocketException- If the login timeout is reached or exceeded.
-
getRealTimeout
protected int getRealTimeout(int expectedTimeout) Validates the connection/socket timeout that must really be used.- Parameters:
expectedTimeout- The timeout to validate.- Returns:
- The timeout to be used.
-