Class ConnectionHelper

java.lang.Object
org.mariadb.jdbc.client.impl.ConnectionHelper

public final class ConnectionHelper extends Object
Connection creation helper class
  • Field Details

  • 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 options
      hostAddress - host ( mandatory but for named pipe / unix socket)
      Returns:
      a nex socket
      Throws:
      IOException - if connection error occur
      SQLException - in case of configuration error
    • standardSocket

      public static Socket standardSocket(Configuration conf, HostAddress hostAddress) throws IOException, SQLException
      Use standard socket implementation.
      Parameters:
      conf - url options
      hostAddress - host to connect
      Returns:
      socket
      Throws:
      IOException - in case of error establishing socket.
      SQLException - in case host is null
    • connectSocket

      public static Socket connectSocket(Configuration conf, HostAddress hostAddress) throws SQLException
      Connect socket
      Parameters:
      conf - configuration
      hostAddress - host to connect
      Returns:
      socket
      Throws:
      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 - configuration
      serverCapabilities - server capabilities
      hostAddress - host address server
      Returns:
      client capabilities
    • initializeBaseCapabilities

      private static long initializeBaseCapabilities()
    • applyOptionalCapabilities

      private static long applyOptionalCapabilities(long capabilities, Configuration configuration)
    • applyTechnicalCapabilities

      private static long applyTechnicalCapabilities(long capabilities, Configuration configuration)
    • applyConnectionCapabilities

      private static long applyConnectionCapabilities(long capabilities, Configuration configuration, HostAddress hostAddress)
    • getBooleanProperty

      private static boolean getBooleanProperty(Configuration configuration, String propertyName, boolean defaultValue)
    • shouldEnableMetadataCache

      private static boolean shouldEnableMetadataCache(Configuration configuration)
    • shouldConnectWithDb

      private static boolean shouldConnectWithDb(Configuration configuration, HostAddress hostAddress)
    • shouldEnableSsl

      private static boolean shouldEnableSsl(Configuration configuration, HostAddress hostAddress)
    • loadCredential

      public static Credential loadCredential(CredentialPlugin credentialPlugin, Configuration configuration, HostAddress hostAddress) throws SQLException
      Load user/password plugin if configured to.
      Parameters:
      credentialPlugin - configuration credential plugin
      configuration - configuration
      hostAddress - current connection host address
      Returns:
      credentials
      Throws:
      SQLException - if configured credential plugin fail
    • enabledSslProtocolSuites

      static void enabledSslProtocolSuites(SSLSocket sslSocket, Configuration conf) throws 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:
      SQLException - if protocol isn't a supported protocol
    • enabledSslCipherSuites

      static void enabledSslCipherSuites(SSLSocket sslSocket, Configuration conf) throws SQLException
      Set ssl socket cipher according to options.
      Parameters:
      sslSocket - current ssl socket
      conf - configuration
      Throws:
      SQLException - if a cipher isn't known