Package org.mariadb.jdbc.client
Class ConnectionHelper
java.lang.Object
org.mariadb.jdbc.client.ConnectionHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
authenticationHandler
(Credential credential, PacketWriter writer, PacketReader reader, Context context) static Socket
connectSocket
(Configuration conf, HostAddress hostAddress) static Socket
createSocket
(Configuration conf, HostAddress hostAddress) Create socket accordingly to options.static byte
decideLanguage
(InitialHandshakePacket handshake) Default collation used for string exchanges with server.(package private) static void
enabledSslCipherSuites
(SSLSocket sslSocket, Configuration conf) Set ssl socket cipher according to options.(package private) static void
enabledSslProtocolSuites
(SSLSocket sslSocket, Configuration conf) Return possible protocols : values of option enabledSslProtocolSuites is set, or default to "TLSv1,TLSv1.1".static long
initializeClientCapabilities
(Configuration configuration, long serverCapabilities) static Credential
loadCredential
(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress) static SSLSocket
sslWrapper
(HostAddress hostAddress, Socket socket, long clientCapabilities, byte exchangeCharset, Context context, PacketWriter writer) static Socket
standardSocket
(Configuration conf, HostAddress hostAddress) Use standard socket implementation.
-
Field Details
-
socketHandler
-
-
Constructor Details
-
ConnectionHelper
public ConnectionHelper()
-
-
Method Details
-
createSocket
public static Socket createSocket(Configuration conf, HostAddress hostAddress) throws IOException, SQLException Create socket accordingly to options.- Parameters:
conf
- Url optionshostAddress
- host ( mandatory but for named pipe / unix socket)- Returns:
- a nex socket
- Throws:
IOException
- if connection error occurSQLException
- in case of configuration error
-
standardSocket
public static Socket standardSocket(Configuration conf, HostAddress hostAddress) throws IOException, SQLException Use standard socket implementation.- Parameters:
conf
- url optionshostAddress
- host to connect- Returns:
- socket
- Throws:
IOException
- in case of error establishing socket.SQLException
- in case host is null
-
connectSocket
- Throws:
SQLException
-
initializeClientCapabilities
public static long initializeClientCapabilities(Configuration configuration, long serverCapabilities) -
decideLanguage
Default collation used for string exchanges with server. Always return 4 bytes utf8 collation for server that permit it.- Parameters:
handshake
- initial handshake packet- Returns:
- collation byte
-
authenticationHandler
public static void authenticationHandler(Credential credential, PacketWriter writer, PacketReader reader, Context context) throws SQLException, IOException - Throws:
SQLException
IOException
-
loadCredential
public static Credential loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress) throws SQLException - Throws:
SQLException
-
sslWrapper
public static SSLSocket sslWrapper(HostAddress hostAddress, Socket socket, long clientCapabilities, byte exchangeCharset, Context context, PacketWriter writer) throws SQLException, IOException - Throws:
SQLException
IOException
-
enabledSslProtocolSuites
Return possible protocols : values of option enabledSslProtocolSuites is set, or default to "TLSv1,TLSv1.1". MariaDB versions ≥ 10.0.15 and ≥ 5.5.41 supports TLSv1.2 if compiled with openSSL (default). MySQL's community versions ≥ 5.7.10 is compiled with yaSSL, so max TLS is TLSv1.1.- Parameters:
sslSocket
- current sslSocket- Throws:
SQLException
- if protocol isn't a supported protocol
-
enabledSslCipherSuites
Set ssl socket cipher according to options.- Parameters:
sslSocket
- current ssl socketconf
- configuration- Throws:
SQLException
- if a cipher isn't known
-