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

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase 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 ServiceOceanBase DataPilotOceanBase OAgent

Connectors and Middleware

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

Databases

OceanBase DatabaseOceanBase AI DatabaseOceanBase Cloud OceanSeekOceanBase 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 ServiceOceanBase DataPilotOceanBase OAgent
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Connector/J

V2.4.5
  • 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
      • Examples
    • 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 of LOB data types
        • LOB data interface
        • LOB locator interface
      • 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 of result sets
      • Limitations
      • FetchSize
      • refreshRow
      • useCursorFetch
    • Batch processing
    • Failover and Load-Balancing
      • Failover and load balancing modes
      • LoadBalance strategies
      • Load balancing strategy configuration methods
    • Load-Balancing
      • Overview of Load-Balancing Modes
    • Rich client
    • Logging
    • 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.5
      • 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.5

Overview of Load-Balancing Modes

Last Updated:2026-10-16 07:14:14

loadbalance mode
replication mode
Related parameters

OceanBase Connector/J supports the following load-balancing modes: loadbalance and replication.

loadbalance mode

The loadbalance mode supports connection load balancing in multi-host environments. This mode does not support load-balanced reads from secondary servers. The connector performs load balancing for all queries by randomly selecting a host from each connection URL. Since connections are randomly distributed across all hosts, queries are load-balanced.

replication mode

The replication mode supports connection load balancing in primary/secondary environments. This mode is suitable for environments with one or more primary hosts. If a connection is set to read-only before reading operations, this mode supports load-balanced reads from secondary servers. The connector performs load balancing by randomly selecting a secondary server from the connection URL to execute read queries.

Related parameters

The related parameters are listed in the following table.

Parameters
Description
autoReconnect If this parameter is enabled and Load-Balancing mode is not used, the connector will only attempt to reconnect to the host after a connection failure. If this parameter is enabled and Load-Balancing mode is used, the connector will blacklist the failed host and attempt to connect to other hosts of the same type. Default value:false.

Notice

When autoReconnect=true is set, correctness risks may occur. Therefore, starting from V2.4.16, the autoReconnect=true configuration is disabled. Setting autoReconnect=true will result in an error. You can only set autoReconnect=false, or not set it at all.

validConnectionTimeout When multiple hosts are configured, the connector will not lose the connection verification within the set duration (in seconds). When this parameter is set to 0, no verification will be performed. Default value: 120 s.
loadBalanceBlacklistTimeout When a connection fails, the host will be added to a blacklist for the duration defined by this parameter. When connecting to a host, the driver attempts to connect to hosts that are not on the blacklist. Only if no host is found will it attempt to connect to a host on the blacklist. This blacklist is shared within the class loader. Default value: 50 ms.
assureReadOnly If you enable this parameter when using load balancing mode and establishing a read-only connection with the host, the session will be set to read-only to ensure this connection remains in read-only mode. Default value:false.
allowMasterDownConnection Using Load-BalancingreplicationIn this mode, connections are allowed to be created when the primary server is shut down. If no primary server is available, connections are made to the secondary server by default.Connection.isReadOnly()will returntrue. Default value:false.

Previous topic

Load balancing strategy configuration methods
Last

Next topic

Rich client
Next
on this page
loadbalance mode
replication mode
Related parameters