OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/J

V2.4.4
  • What is OceanBase Connector J?
    • Overview of OceanBase Connector/J
    • Compatibility requirements
  • Install Driver
    • Install and load the OceanBase Connector/J driver
  • Instructions
    • Quick start
      • Import packages
      • Create a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process ResultSet objects
      • Close ResultSet and Statement objects
      • Manage tables and data
      • Commit changes
      • Close a database connection
      • Example
    • Data sources and URL
      • Data source overview
      • Database URL
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • Use LOBs
        • Overview
        • LOB data interface
        • LOB locator API
      • CHAR, VARCHAR, and RAW data types
    • Statement caching
      • Overview of statement caching
      • Use statement caching
      • Reuse statement objects
    • Call a stored procedure
    • Handle SQL exceptions
    • Result set
      • Overview
      • Limitations
      • FetchSize
      • refreshRow
      • useCursorFetch
    • Batch processing
    • Failover and Load-Balancing
      • Failover and load balancing modes
      • LoadBalance strategies
      • Load balancing strategy configuration methods
    • Rich client
    • Logging feature
    • Network overheads
    • Show Trace
    • Security features
    • Troubleshooting
  • Reference
    • Features specific to the Oracle mode
      • Binary Protocol (Prepared Statements)
        • COM_STMT_PREPARE_EXECUTE
        • COM_STMT_SEND_PIECE_DATA
      • Call PL stored procedures
      • Scrollability of a result set
      • Use ARRAY and STRUCT classes
      • Distributed transactions
        • Overview
        • XA components
        • Distributed transaction examples
      • Obtain comments
      • Data types supported in Oracle mode
      • Error messages in Oracle mode
    • Supported SQL and PL data types
    • Common APIs
      • Overview
      • java.sql.Connection
      • java.sql.CallableStatement
      • java.sql.DatabaseMetaData
      • java.sql.Driver
      • java.sql.PreparedStatement
      • java.sql.ParameterMetaData
      • java.sql.ResultSet
      • java.sql.ResultSetMetaData
      • java.sql.Statement
      • javax.sql.ConnectionPoolDataSource
      • javax.naming.Context
      • javax.sql.PooledConnection
      • com.oceanbase.jdbc.ObPrepareStatement
  • Release Notes
    • V2.4
      • OceanBase Connector/J V2.4.4
      • OceanBase Connector/J V2.4.3
      • OceanBase Connector/J V2.4.2
      • OceanBase Connector/J V2.4.1
      • OceanBase Connector/J V2.4.0
    • V2.2
      • OceanBase Connector/J V2.2.11
      • OceanBase Connector/J V2.2.10
      • OceanBase Connector/J V2.2.7
      • OceanBase Connector/J V2.2.6
      • OceanBase Connector/J V2.2.3
      • OceanBase Connector/J V2.2.0

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Connector/J
  3. V2.4.4

Failover and load balancing modes

Last Updated:2026-09-04 08:24:26

Sequential mode
Loadbalance mode
Replication mode
Related parameters

OceanBase Connector/J supports three failover and load balancing modes: sequential, loadbalance, and replication.

Sequential mode

The sequential mode supports connection failover in a multi-host environment. This mode does not allow secondary servers to perform load-balanced reads. OceanBase Connector/J attempts to connect to the hosts in the sequence specified in the connection URL, so the first available host is used for all queries. The connection URL is as follows:

jdbc:oceanbasedb:sequential:host1,host2,host3,host4/testobdb

OceanBase Connector/J first attempts to connect to host1. If the host is unavailable, OceanBase Connector/J attempts to connect to host2. When a host fails, OceanBase Connector/J attempts to reconnect to a host in the same sequence.

Loadbalance mode

The loadbalance mode supports connection load balancing in a multi-host environment. This mode does not allow secondary servers to perform load-balanced reads. OceanBase Connector/J randomly selects a host from each connection URL to implement load balancing for all queries. The connections are randomly distributed across all hosts, achieving load balancing for queries.

Replication mode

The replication mode supports connection load balancing in a primary/secondary deployment. This mode applies to environments with one or more hosts. This mode allows secondary servers to handle read queries for load balancing if the connection is set to read-only beforehand. OceanBase Connector/J randomly selects a secondary server from the connection URL to handle read queries for load balancing.

Related parameters

The following table describes the parameters.

Parameter
Description
autoReconnect If this parameter is enabled and no failover or load balancing mode is in use, OceanBase Connector/J only attempts to reconnect to the host after the connection fails, which is called basic failover. If this parameter is enabled and a failover and load balancing mode is in use, OceanBase Connector/J blocklists the failed host and attempts to connect to other hosts of the same type, which is called standard failover. The default value is false.
retriesAllDown If all hosts are down during a failover, this parameter is used to define the maximum number of connection retries allowed for OceanBase Connector/J. The default value is 120.
failoverLoopRetries When OceanBase Connector/J silently searches for available hosts, this parameter specifies the maximum number of connection retries allowed for OceanBase Connector/J. This parameter is different from retriesAllDown. The silent search is used for temporary solutions of OceanBase Connector/J. For example, the primary connection is used to handle read queries when a secondary connection fails. The default value is 120.
validConnectionTimeout When multiple hosts are configured, OceanBase Connector/J holds the verification connection within the specified duration (in seconds). When this parameter is set to 0, no verification is performed. The default value is 120.
loadBalanceBlacklistTimeout When a connection fails, the host is added to the blocklist and blocked for the duration defined by this parameter. OceanBase Connector/J preferentially attempts to connect to a host that is not in the blocklist. It attempts to connect to a host that is in the blocklist only when no host is found. The blocklist is shared within the class loader. The default value is 50 ms.
assureReadOnly If this parameter is enabled when a failover and load balancing mode is in use and a read-only connection is established to the host, the session is set to be read-only to ensure that the connection is in read-only mode. The default value is false.
allowMasterDownConnection If this parameter is enabled in replication mode, a connection can be created when the primary server is down. If no primary server is available, OceanBase Connector/J connects to a secondary server, and Connection.isReadOnly() returns true. The default value is false.

Previous topic

Batch processing
Last

Next topic

LoadBalance strategies
Next
on this page
Sequential mode
Loadbalance mode
Replication mode
Related parameters