Class Configuration


  • public class Configuration
    extends java.lang.Object
    parse and verification of URL.

    basic syntax :
    jdbc:mariadb:[replication:|failover|loadbalance:|aurora:]//<hostDescription>[,<hostDescription>]/[database>] [?<key1>=<value1>[&<key2>=<value2>]]

    hostDescription:
    - simple :
    <host>:<portnumber>
    (for example localhost:3306)

    - complex :
    address=[(type=(master|slave))][(port=<portnumber>)](host=<host>)


    type is by default master
    port is by default 3306

    host can be dns name, ipv4 or ipv6.
    in case of ipv6 and simple host description, the ip must be written inside bracket.
    exemple : jdbc:mariadb://[2001:0660:7401:0200:0000:0000:0edf:bdd7]:3306

    Some examples :
    jdbc:mariadb://localhost:3306/database?user=greg&password=pass
    jdbc:mariadb://address=(type=master)(host=master1),address=(port=3307)(type=slave)(host=slave1)/database?user=greg&password=pass

    • Field Detail

      • URL_PARAMETER

        private static final java.util.regex.Pattern URL_PARAMETER
      • user

        private java.lang.String user
      • password

        private java.lang.String password
      • database

        private java.lang.String database
      • addresses

        private java.util.List<HostAddress> addresses
      • haMode

        private HaMode haMode
      • initialUrl

        private java.lang.String initialUrl
      • nonMappedOptions

        private java.util.Properties nonMappedOptions
      • timezone

        private java.lang.String timezone
      • autocommit

        private boolean autocommit
      • useMysqlMetadata

        private boolean useMysqlMetadata
      • defaultFetchSize

        private int defaultFetchSize
      • maxQuerySizeToLog

        private int maxQuerySizeToLog
      • geometryDefaultType

        private java.lang.String geometryDefaultType
      • restrictedAuth

        private java.lang.String restrictedAuth
      • socketFactory

        private java.lang.String socketFactory
      • connectTimeout

        private int connectTimeout
      • pipe

        private java.lang.String pipe
      • localSocket

        private java.lang.String localSocket
      • tcpKeepAlive

        private boolean tcpKeepAlive
      • tcpKeepIdle

        private int tcpKeepIdle
      • tcpKeepCount

        private int tcpKeepCount
      • tcpKeepInterval

        private int tcpKeepInterval
      • tcpAbortiveClose

        private boolean tcpAbortiveClose
      • localSocketAddress

        private java.lang.String localSocketAddress
      • socketTimeout

        private int socketTimeout
      • useReadAheadInput

        private boolean useReadAheadInput
      • tlsSocketType

        private java.lang.String tlsSocketType
      • serverSslCert

        private java.lang.String serverSslCert
      • keyStore

        private java.lang.String keyStore
      • keyStorePassword

        private java.lang.String keyStorePassword
      • keyStoreType

        private java.lang.String keyStoreType
      • enabledSslCipherSuites

        private java.lang.String enabledSslCipherSuites
      • enabledSslProtocolSuites

        private java.lang.String enabledSslProtocolSuites
      • allowMultiQueries

        private boolean allowMultiQueries
      • allowLocalInfile

        private boolean allowLocalInfile
      • useCompression

        private boolean useCompression
      • useAffectedRows

        private boolean useAffectedRows
      • useBulkStmts

        private boolean useBulkStmts
      • cachePrepStmts

        private boolean cachePrepStmts
      • prepStmtCacheSize

        private int prepStmtCacheSize
      • useServerPrepStmts

        private boolean useServerPrepStmts
      • sessionVariables

        private java.lang.String sessionVariables
      • connectionAttributes

        private java.lang.String connectionAttributes
      • servicePrincipalName

        private java.lang.String servicePrincipalName
      • blankTableNameMeta

        private boolean blankTableNameMeta
      • tinyInt1isBit

        private boolean tinyInt1isBit
      • yearIsDateType

        private boolean yearIsDateType
      • dumpQueriesOnException

        private boolean dumpQueriesOnException
      • includeInnodbStatusInDeadlockExceptions

        private boolean includeInnodbStatusInDeadlockExceptions
      • includeThreadDumpInDeadlockExceptions

        private boolean includeThreadDumpInDeadlockExceptions
      • retriesAllDown

        private int retriesAllDown
      • galeraAllowedState

        private java.lang.String galeraAllowedState
      • transactionReplay

        private boolean transactionReplay
      • pool

        private boolean pool
      • poolName

        private java.lang.String poolName
      • maxPoolSize

        private int maxPoolSize
      • minPoolSize

        private int minPoolSize
      • maxIdleTime

        private int maxIdleTime
      • registerJmxPool

        private boolean registerJmxPool
      • poolValidMinDelay

        private int poolValidMinDelay
      • useResetConnection

        private boolean useResetConnection
      • serverRsaPublicKeyFile

        private java.lang.String serverRsaPublicKeyFile
      • allowPublicKeyRetrieval

        private boolean allowPublicKeyRetrieval
      • codecs

        private Codec<?>[] codecs
    • Constructor Detail

      • Configuration

        private Configuration()
      • Configuration

        private Configuration​(java.lang.String user,
                              java.lang.String password,
                              java.lang.String database,
                              java.util.List<HostAddress> addresses,
                              HaMode haMode,
                              java.util.Properties nonMappedOptions,
                              java.lang.String timezone,
                              boolean autocommit,
                              boolean useMysqlMetadata,
                              TransactionIsolation transactionIsolation,
                              int defaultFetchSize,
                              int maxQuerySizeToLog,
                              java.lang.String geometryDefaultType,
                              java.lang.String restrictedAuth,
                              java.lang.String socketFactory,
                              int connectTimeout,
                              java.lang.String pipe,
                              java.lang.String localSocket,
                              boolean tcpKeepAlive,
                              int tcpKeepIdle,
                              int tcpKeepCount,
                              int tcpKeepInterval,
                              boolean tcpAbortiveClose,
                              java.lang.String localSocketAddress,
                              int socketTimeout,
                              boolean useReadAheadInput,
                              java.lang.String tlsSocketType,
                              SslMode sslMode,
                              java.lang.String serverSslCert,
                              java.lang.String keyStore,
                              java.lang.String keyStorePassword,
                              java.lang.String keyStoreType,
                              java.lang.String enabledSslCipherSuites,
                              java.lang.String enabledSslProtocolSuites,
                              boolean allowMultiQueries,
                              boolean allowLocalInfile,
                              boolean useCompression,
                              boolean useAffectedRows,
                              boolean useBulkStmts,
                              boolean cachePrepStmts,
                              int prepStmtCacheSize,
                              boolean useServerPrepStmts,
                              CredentialPlugin credentialType,
                              java.lang.String sessionVariables,
                              java.lang.String connectionAttributes,
                              java.lang.String servicePrincipalName,
                              boolean blankTableNameMeta,
                              boolean tinyInt1isBit,
                              boolean yearIsDateType,
                              boolean dumpQueriesOnException,
                              boolean includeInnodbStatusInDeadlockExceptions,
                              boolean includeThreadDumpInDeadlockExceptions,
                              int retriesAllDown,
                              java.lang.String galeraAllowedState,
                              boolean transactionReplay,
                              boolean pool,
                              java.lang.String poolName,
                              int maxPoolSize,
                              int minPoolSize,
                              int maxIdleTime,
                              boolean registerJmxPool,
                              int poolValidMinDelay,
                              boolean useResetConnection,
                              java.lang.String serverRsaPublicKeyFile,
                              boolean allowPublicKeyRetrieval)
      • Configuration

        private Configuration​(java.lang.String database,
                              java.util.List<HostAddress> addresses,
                              HaMode haMode,
                              java.lang.String user,
                              java.lang.String password,
                              java.lang.String enabledSslProtocolSuites,
                              java.lang.String socketFactory,
                              java.lang.Integer connectTimeout,
                              java.lang.String pipe,
                              java.lang.String localSocket,
                              java.lang.Boolean tcpKeepAlive,
                              java.lang.Integer tcpKeepIdle,
                              java.lang.Integer tcpKeepCount,
                              java.lang.Integer tcpKeepInterval,
                              java.lang.Boolean tcpAbortiveClose,
                              java.lang.String localSocketAddress,
                              java.lang.Integer socketTimeout,
                              java.lang.Boolean allowMultiQueries,
                              java.lang.Boolean allowLocalInfile,
                              java.lang.Boolean useCompression,
                              java.lang.Boolean blankTableNameMeta,
                              java.lang.String credentialType,
                              java.lang.String sslMode,
                              java.lang.String transactionIsolation,
                              java.lang.String enabledSslCipherSuites,
                              java.lang.String sessionVariables,
                              java.lang.Boolean tinyInt1isBit,
                              java.lang.Boolean yearIsDateType,
                              java.lang.String timezone,
                              java.lang.Boolean dumpQueriesOnException,
                              java.lang.Integer prepStmtCacheSize,
                              java.lang.Boolean useAffectedRows,
                              java.lang.Boolean useServerPrepStmts,
                              java.lang.String connectionAttributes,
                              java.lang.Boolean useBulkStmts,
                              java.lang.Boolean autocommit,
                              java.lang.Boolean useMysqlMetadata,
                              java.lang.Boolean includeInnodbStatusInDeadlockExceptions,
                              java.lang.Boolean includeThreadDumpInDeadlockExceptions,
                              java.lang.String servicePrincipalName,
                              java.lang.Integer defaultFetchSize,
                              java.lang.String tlsSocketType,
                              java.lang.Integer maxQuerySizeToLog,
                              java.lang.Integer retriesAllDown,
                              java.lang.String galeraAllowedState,
                              java.lang.Boolean pool,
                              java.lang.String poolName,
                              java.lang.Integer maxPoolSize,
                              java.lang.Integer minPoolSize,
                              java.lang.Integer maxIdleTime,
                              java.lang.Boolean registerJmxPool,
                              java.lang.Integer poolValidMinDelay,
                              java.lang.Boolean useResetConnection,
                              java.lang.String serverRsaPublicKeyFile,
                              java.lang.Boolean allowPublicKeyRetrieval,
                              java.lang.String serverSslCert,
                              java.lang.String keyStore,
                              java.lang.String keyStorePassword,
                              java.lang.String keyStoreType,
                              java.lang.Boolean useReadAheadInput,
                              java.lang.Boolean cachePrepStmts,
                              java.lang.Boolean transactionReplay,
                              java.lang.String geometryDefaultType,
                              java.lang.String restrictedAuth,
                              java.util.Properties nonMappedOptions)
                       throws java.sql.SQLException
        Throws:
        java.sql.SQLException
    • Method Detail

      • acceptsUrl

        public static boolean acceptsUrl​(java.lang.String url)
        Tell if mariadb driver accept url string. (Correspond to interface java.jdbc.Driver.acceptsURL() method)
        Parameters:
        url - url String
        Returns:
        true if url string correspond.
      • parse

        public static Configuration parse​(java.lang.String url)
                                   throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • parse

        public static Configuration parse​(java.lang.String url,
                                          java.util.Properties prop)
                                   throws java.sql.SQLException
        Parse url connection string with additional properties.
        Parameters:
        url - connection string
        prop - properties
        Returns:
        UrlParser instance
        Throws:
        java.sql.SQLException - if parsing exception occur
      • parseInternal

        private static Configuration parseInternal​(java.lang.String url,
                                                   java.util.Properties properties)
                                            throws java.sql.SQLException
        Parses the connection URL in order to set the UrlParser instance with all the information provided through the URL.
        Parameters:
        url - connection URL
        properties - properties
        Throws:
        java.sql.SQLException - if format is incorrect
      • mapPropertiesToOption

        private static void mapPropertiesToOption​(Configuration.Builder builder,
                                                  java.util.Properties properties)
      • isSet

        private static boolean isSet​(java.lang.String key,
                                     java.util.Properties nonMappedOptions)
      • parseHaMode

        private static HaMode parseHaMode​(java.lang.String url,
                                          int separator)
      • clone

        public Configuration clone​(java.lang.String username,
                                   java.lang.String password)
      • database

        public java.lang.String database()
      • addresses

        public java.util.List<HostAddress> addresses()
      • haMode

        public HaMode haMode()
      • user

        public java.lang.String user()
      • password

        public java.lang.String password()
      • initialUrl

        public java.lang.String initialUrl()
      • serverSslCert

        public java.lang.String serverSslCert()
      • keyStore

        public java.lang.String keyStore()
      • keyStorePassword

        public java.lang.String keyStorePassword()
      • keyStoreType

        public java.lang.String keyStoreType()
      • enabledSslProtocolSuites

        public java.lang.String enabledSslProtocolSuites()
      • socketFactory

        public java.lang.String socketFactory()
      • connectTimeout

        public int connectTimeout()
      • connectTimeout

        public Configuration connectTimeout​(int connectTimeout)
      • pipe

        public java.lang.String pipe()
      • localSocket

        public java.lang.String localSocket()
      • tcpKeepAlive

        public boolean tcpKeepAlive()
      • tcpKeepIdle

        public int tcpKeepIdle()
      • tcpKeepCount

        public int tcpKeepCount()
      • tcpKeepInterval

        public int tcpKeepInterval()
      • tcpAbortiveClose

        public boolean tcpAbortiveClose()
      • localSocketAddress

        public java.lang.String localSocketAddress()
      • socketTimeout

        public int socketTimeout()
      • allowMultiQueries

        public boolean allowMultiQueries()
      • allowLocalInfile

        public boolean allowLocalInfile()
      • useCompression

        public boolean useCompression()
      • blankTableNameMeta

        public boolean blankTableNameMeta()
      • sslMode

        public SslMode sslMode()
      • enabledSslCipherSuites

        public java.lang.String enabledSslCipherSuites()
      • sessionVariables

        public java.lang.String sessionVariables()
      • tinyInt1isBit

        public boolean tinyInt1isBit()
      • yearIsDateType

        public boolean yearIsDateType()
      • timezone

        public java.lang.String timezone()
      • dumpQueriesOnException

        public boolean dumpQueriesOnException()
      • prepStmtCacheSize

        public int prepStmtCacheSize()
      • useAffectedRows

        public boolean useAffectedRows()
      • useServerPrepStmts

        public boolean useServerPrepStmts()
      • connectionAttributes

        public java.lang.String connectionAttributes()
      • useBulkStmts

        public boolean useBulkStmts()
      • autocommit

        public boolean autocommit()
      • useMysqlMetadata

        public boolean useMysqlMetadata()
      • includeInnodbStatusInDeadlockExceptions

        public boolean includeInnodbStatusInDeadlockExceptions()
      • includeThreadDumpInDeadlockExceptions

        public boolean includeThreadDumpInDeadlockExceptions()
      • servicePrincipalName

        public java.lang.String servicePrincipalName()
      • defaultFetchSize

        public int defaultFetchSize()
      • nonMappedOptions

        public java.util.Properties nonMappedOptions()
      • tlsSocketType

        public java.lang.String tlsSocketType()
      • maxQuerySizeToLog

        public int maxQuerySizeToLog()
      • retriesAllDown

        public int retriesAllDown()
      • galeraAllowedState

        public java.lang.String galeraAllowedState()
      • pool

        public boolean pool()
      • poolName

        public java.lang.String poolName()
      • maxPoolSize

        public int maxPoolSize()
      • minPoolSize

        public int minPoolSize()
      • maxIdleTime

        public int maxIdleTime()
      • registerJmxPool

        public boolean registerJmxPool()
      • poolValidMinDelay

        public int poolValidMinDelay()
      • useResetConnection

        public boolean useResetConnection()
      • serverRsaPublicKeyFile

        public java.lang.String serverRsaPublicKeyFile()
      • allowPublicKeyRetrieval

        public boolean allowPublicKeyRetrieval()
      • useReadAheadInput

        public boolean useReadAheadInput()
      • cachePrepStmts

        public boolean cachePrepStmts()
      • transactionReplay

        public boolean transactionReplay()
      • geometryDefaultType

        public java.lang.String geometryDefaultType()
      • restrictedAuth

        public java.lang.String restrictedAuth()
      • codecs

        public Codec<?>[] codecs()
      • toString

        public java.lang.String toString()
        ToString implementation.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String value
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • buildUrl

        protected static java.lang.String buildUrl​(Configuration conf)
      • loadCodecs

        private void loadCodecs()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • nullOrEmpty

        private static java.lang.String nullOrEmpty​(java.lang.String val)