Package org.mariadb.jdbc.client.impl
Class ConnectionHelper
- java.lang.Object
-
- org.mariadb.jdbc.client.impl.ConnectionHelper
-
public final class ConnectionHelper extends java.lang.Object
Connection creation helper class
-
-
Field Summary
Fields Modifier and Type Field Description private static SocketHandlerFunction
socketHandler
-
Constructor Summary
Constructors Constructor Description ConnectionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.net.Socket
connectSocket(Configuration conf, HostAddress hostAddress)
Connect socketstatic java.net.Socket
createSocket(Configuration conf, HostAddress hostAddress)
Create socket accordingly to options.(package private) static void
enabledSslCipherSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf)
Set ssl socket cipher according to options.(package private) static void
enabledSslProtocolSuites(javax.net.ssl.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, HostAddress hostAddress)
Initialize client capability according to configuration and server capabilities.static Credential
loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress)
Load user/password plugin if configured to.static java.net.Socket
standardSocket(Configuration conf, HostAddress hostAddress)
Use standard socket implementation.
-
-
-
Field Detail
-
socketHandler
private static final SocketHandlerFunction socketHandler
-
-
Method Detail
-
createSocket
public static java.net.Socket createSocket(Configuration conf, HostAddress hostAddress) throws java.io.IOException, java.sql.SQLException
Create socket accordingly to options.- Parameters:
conf
- Url optionshostAddress
- host ( mandatory but for named pipe / unix socket)- Returns:
- a nex socket
- Throws:
java.io.IOException
- if connection error occurjava.sql.SQLException
- in case of configuration error
-
standardSocket
public static java.net.Socket standardSocket(Configuration conf, HostAddress hostAddress) throws java.io.IOException, java.sql.SQLException
Use standard socket implementation.- Parameters:
conf
- url optionshostAddress
- host to connect- Returns:
- socket
- Throws:
java.io.IOException
- in case of error establishing socket.java.sql.SQLException
- in case host is null
-
connectSocket
public static java.net.Socket connectSocket(Configuration conf, HostAddress hostAddress) throws java.sql.SQLException
Connect socket- Parameters:
conf
- configurationhostAddress
- host to connect- Returns:
- socket
- Throws:
java.sql.SQLException
- if hostname is required and not provided, or socket cannot be created
-
initializeClientCapabilities
public static long initializeClientCapabilities(Configuration configuration, long serverCapabilities, HostAddress hostAddress)
Initialize client capability according to configuration and server capabilities.- Parameters:
configuration
- configurationserverCapabilities
- server capabilitieshostAddress
- host address server- Returns:
- client capabilities
-
loadCredential
public static Credential loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress) throws java.sql.SQLException
Load user/password plugin if configured to.- Parameters:
credentialPlugin
- configuration credential pluginconfiguration
- configurationhostAddress
- current connection host address- Returns:
- credentials
- Throws:
java.sql.SQLException
- if configured credential plugin fail
-
enabledSslProtocolSuites
static void enabledSslProtocolSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf) throws java.sql.SQLException
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:
java.sql.SQLException
- if protocol isn't a supported protocol
-
enabledSslCipherSuites
static void enabledSslCipherSuites(javax.net.ssl.SSLSocket sslSocket, Configuration conf) throws java.sql.SQLException
Set ssl socket cipher according to options.- Parameters:
sslSocket
- current ssl socketconf
- configuration- Throws:
java.sql.SQLException
- if a cipher isn't known
-
-