Documentation Home
MySQL Connector/J 5.1 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb


5.3.3 High Availability and Clustering

  • autoReconnect

    Should the driver try to re-establish stale and/or dead connections? If enabled the driver will throw an exception for a queries issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction. The use of this feature is not recommended, because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly. Alternatively, as a last option, investigate setting the MySQL server variable "wait_timeout" to a high value, rather than the default of 8 hours.

    Default Value false
    Since Version 1.1
  • autoReconnectForPools

    Use a reconnection strategy appropriate for connection pools (defaults to 'false')

    Default Value false
    Since Version 3.1.3
  • failOverReadOnly

    When failing over in autoReconnect mode, should the connection be set to 'read-only'?

    Default Value true
    Since Version 3.0.12
  • maxReconnects

    Maximum number of reconnects to attempt if autoReconnect is true, default is '3'.

    Default Value 3
    Since Version 1.1
  • reconnectAtTxEnd

    If autoReconnect is set to true, should the driver attempt reconnections at the end of every transaction?

    Default Value false
    Since Version 3.0.10
  • retriesAllDown

    When using loadbalancing or failover, the number of times the driver should cycle through available hosts, attempting to connect. Between cycles, the driver will pause for 250ms if no servers are available.

    Default Value 120
    Since Version 5.1.6
  • initialTimeout

    If autoReconnect is enabled, the initial time to wait between re-connect attempts (in seconds, defaults to '2').

    Default Value 2
    Since Version 1.1
  • roundRobinLoadBalance

    When autoReconnect is enabled, and failoverReadonly is false, should we pick hosts to connect to on a round-robin basis?

    Default Value false
    Since Version 3.1.2
  • queriesBeforeRetryMaster

    Number of queries to issue before falling back to the primary host when failed over (when using multi-host failover). Whichever condition is met first, 'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an attempt to be made to reconnect to the primary host. Setting both properties to 0 disables the automatic fall back to the primary host at transaction boundaries. Defaults to 50.

    Default Value 50
    Since Version 3.0.2
  • secondsBeforeRetryMaster

    How long should the driver wait, when failed over, before attempting to reconnect to the primary host? Whichever condition is met first, 'queriesBeforeRetryMaster' or 'secondsBeforeRetryMaster' will cause an attempt to be made to reconnect to the source. Setting both properties to 0 disables the automatic fall back to the primary host at transaction boundaries. Time in seconds, defaults to 30

    Default Value 30
    Since Version 3.0.2
  • allowMasterDownConnections

    By default, a replication-aware connection will fail to connect when configured source hosts are all unavailable at initial connection. Setting this property to 'true' allows to establish the initial connection, by failing over to the replica servers, in read-only state. It won't prevent subsequent failures when switching back to the source hosts i.e. by setting the replication connection to read/write state.

    Default Value false
    Since Version 5.1.27
  • allowSlaveDownConnections

    By default, a replication-aware connection will fail to connect when configured replica hosts are all unavailable at initial connection. Setting this property to 'true' allows to establish the initial connection. It won't prevent failures when switching to replicas i.e. by setting the replication connection to read-only state. The property 'readFromMasterWhenNoSlaves' should be used for this purpose.

    Default Value false
    Since Version 5.1.38
  • readFromMasterWhenNoSlaves

    Replication-aware connections distribute load by using the source hosts when in read/write state and by using the replica hosts when in read-only state. If, when setting the connection to read-only state, none of the replica hosts are available, an SQLExeception is thrown back. Setting this property to 'true' allows to fail over to the source hosts, while setting the connection state to read-only, when no replica hosts are available at switch instant.

    Default Value false
    Since Version 5.1.38
  • replicationEnableJMX

    Enables JMX-based management of load-balanced connection groups, including live addition/removal of hosts from load-balancing pool.

    Default Value false
    Since Version 5.1.27
  • selfDestructOnPingMaxOperations

    If set to a non-zero value, the driver will report close the connection and report failure when Connection.ping() or Connection.isValid(int) is called if the connection's count of commands sent to the server exceeds this value.

    Default Value 0
    Since Version 5.1.6
  • selfDestructOnPingSecondsLifetime

    If set to a non-zero value, the driver will close the connection and report failure when Connection.ping() or Connection.isValid(int) is called if the connection's lifetime exceeds this value (in milliseconds).

    Default Value 0
    Since Version 5.1.6
  • replicationConnectionGroup

    Logical group of replication connections within a classloader, used to manage different groups independently. If not specified, live management of replication connections is disabled.

    Since Version 5.1.27
  • resourceId

    A globally unique name that identifies the resource that this datasource or connection is connected to, used for XAResource.isSameRM() when the driver can't determine this value based on hostnames used in the URL

    Since Version 5.0.1