Top Description Methods
com.mysql.cj.protocol

public Interface SocketFactory

extends SocketMetadata
Known Direct Implementers
com.mysql.cj.protocol.StandardSocketFactory, com.mysql.jdbc.SocketFactoryWrapper, com.mysql.cj.protocol.NamedPipeSocketFactory
Imports
java.io.Closeable, .IOException, com.mysql.cj.conf.PropertySet, com.mysql.cj.log.Log

Interface to allow pluggable socket creation in the driver

Method Summary

Modifier and TypeMethod and Description
public default void
afterHandshake()

Called by the driver after completing the MySQL protocol handshake and reading the results of the authentication.

public default void
beforeHandshake()

Called by the driver before issuing the MySQL protocol handshake.

public <
result type
T extends Closeable
>
T

Returns:

a socket connected to the given host
connect
(String
the hostname passed in the URL. It will be a single hostname, as the driver parses multi-hosts (for failover) and calls this method for each host connection attempt.
host
,
int
the port number to connect to (if required).
portNumber
,
PropertySet
properties passed to the driver via the URL and/or properties instance.
props
,
int
login timeout in milliseconds
loginTimeout
)

Creates a new socket or channel using the given properties.

public <
result type
T extends Closeable
>
T

Returns:

SSL socket
performTlsHandshake
(SocketConnection
current SocketConnection
socketConnection
,
ServerSession
current ServerSession
serverSession
)

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

public default <
result type
T extends Closeable
>
T

Returns:

SSL socket
performTlsHandshake
(SocketConnection
current SocketConnection
socketConnection
,
ServerSession
current ServerSession
serverSession
,
Log
logger
log
)

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Inherited from com.mysql.cj.protocol.SocketMetadata:
isLocallyConnectedisLocallyConnected

Method Detail

afterHandshakeback to summary
public default void afterHandshake() throws IOException

Called by the driver after completing the MySQL protocol handshake and reading the results of the authentication.

Exceptions
IOException:
if an I/O error occurs
beforeHandshakeback to summary
public default void beforeHandshake() throws IOException

Called by the driver before issuing the MySQL protocol handshake.

Exceptions
IOException:
if an I/O error occurs
connectback to summary
public <T extends Closeable> T connect(String host, int portNumber, PropertySet props, int loginTimeout) throws IOException

Creates a new socket or channel 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 is com.mysql.cj.protocol.StandardSocketFactory Implementing classes are responsible for handling synchronization of this method (if needed).

Parameters
<T>
result type
host:String

the hostname passed in the 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:int

the port number to connect to (if required).

props:PropertySet

properties passed to the driver via the URL and/or properties instance.

loginTimeout:int

login timeout in milliseconds

Returns:T

a socket connected to the given host

Exceptions
IOException:
if an I/O error occurs
performTlsHandshakeback to summary
public <T extends Closeable> T performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession) throws IOException

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Parameters
<T>
result type
socketConnection:SocketConnection

current SocketConnection

serverSession:ServerSession

current ServerSession

Returns:T

SSL socket

Exceptions
IOException:
if an I/O error occurs
performTlsHandshakeback to summary
public default <T extends Closeable> T performTlsHandshake(SocketConnection socketConnection, ServerSession serverSession, Log log) throws IOException

If required, called by the driver during MySQL protocol handshake to transform original socket to SSL socket and perform TLS handshake.

Parameters
<T>
result type
socketConnection:SocketConnection

current SocketConnection

serverSession:ServerSession

current ServerSession

log:Log

logger

Returns:T

SSL socket

Exceptions
IOException:
if an I/O error occurs