OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Connector/J

V2.4.17

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

Download PDF

Compatibility requirements Overview of OceanBase Connector/J Install and load OceanBase Connector/J Handle SQL exceptions Batch processing Rich client Show Trace Show Trace Security features Call a stored procedure Network overheads Troubleshooting Database URL Data source overview clientInfoProvider Manage tables and data Close a database connection Process ResultSet objects Close ResultSet and Statement objects Commit changes Create a Statement object Run queries and retrieve ResultSet objects Examples Import packages Establish a database connection Overview of result sets useCursorFetch FetchSize Limitations refreshRow Overview of Java data streams LONG and LONG RAW data types CHAR, VARCHAR, and RAW data types LoadBalance strategies Failover and load balancing modes Load balancing strategy configuration methods Overview of statement caching Reuse statement objects Use statement caching Supported SQL and PL data types Call PL stored procedures Scrollability of a result set Use ARRAY and STRUCT classes Obtain remarks Data types supported in Oracle mode Error messages in Oracle mode Overview java.sql.ResultSet javax.naming.Context javax.sql.ConnectionPoolDataSource java.sql.DatabaseMetaData java.sql.ParameterMetaData java.sql.Statement javax.sql.PooledConnection java.sql.ResultSetMetaData java.sql.Driver java.sql.CallableStatement com.oceanbase.jdbc.ObPrepareStatement java.sql.Connection java.sql.PreparedStatement OceanBase Connector/J V2.4.17 OceanBase Connector/J V2.4.16 OceanBase Connector/J V2.4.15 OceanBase Connector/J V2.4.14 OceanBase Connector/J V2.4.13 OceanBase Connector/J V2.4.12 OceanBase Connector/J V2.4.11 OceanBase Connector/J V2.4.8 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 OceanBase Connector/J V2.2.11 OceanBase Connector/J V2.2.7 OceanBase Connector/J V2.2.0 OceanBase Connector/J V2.2.6 OceanBase Connector/J V2.2.3 OceanBase Connector/J V2.2.10
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Connector/J
  3. V2.4.17
iconOceanBase Connector/J
V 2.4.17
  • V 2.4.17
  • V 2.4.16
  • V 2.4.15
  • V 2.4.14
  • V 2.4.5
  • V 2.4.4
  • V 2.4.3
  • V 2.4.2
  • V 2.4.1
  • V 2.4.0
  • V 2.2.11
  • V 2.2.10
  • V 2.2.7
  • V 2.2.6
  • V 2.2.3
  • V 2.2.0

LoadBalance strategies

Last Updated:2026-04-10 06:56:35  Updated
share
What is on this page
Load balancing strategies
Load balancing group selection strategy
Blocklist strategies
Examples of blocklist strategies
Related parameters

folded

share

The LoadBalance mode of OceanBase Connector/J is used for the creation of each Connection object. Each time a Connection object is created, OceanBase Connector/J selects a host from the host list by using the load balancing strategy to establish the connection. LoadBalance based on a configuration file can monitor the corresponding configuration file directory and detect changes after the configuration file is updated. The load balancing strategy, host list, and other information can be updated without modifying the URL each time getConnection is executed.

Load balancing strategies

You can implement three load balancing strategies of OceanBase Connector/J by configuring the OBLB_STRATEGY and LOAD_BALANCE_STRATEGY parameters in the extended configuration information and the loadBalanceStrategy parameter in the URL. The following table describes the strategies.

Algorithm Feature Remarks
RANDOM Random load balancing Specifies to use the random algorithm, which is the default load balancing algorithm.
SERVERAFFINITY Weighted load balancing Specifies to use the weighted random algorithm.
ROTATION Rotation load balancing Specifies to use the rotation load balancing algorithm.

Load balancing group selection strategy

OceanBase Connector/J supports only one strategy for load balancing between multiple groups of hosts, which corresponds to the OBLB_GROUP_STRATEGY parameter in the extended configuration information. The following table describes the strategy.

Algorithm Feature Remarks
ROTATION Rotation load balancing Specifies to use the rotation load balancing algorithm, which is the default load balancing algorithm.

Blocklist strategies

OceanBase Connector/J allows you to specify strategies for removing and adding blocklist entries with two sub-parameters of OBLB_BLACKLIST. Use the REMOVE_STRATEGY sub-parameter to configure removal strategies, and the APPEND_STRATEGY sub-parameter to configure addition strategies.

OceanBase Connector/J supports two blocklist entry addition strategies, which correspond to the APPEND_STRATEGY sub-parameter. The following table describes the strategies.

Algorithm Feature Remarks
NORMAL Normal strategy The default strategy, which specifies to add a host to the blocklist when a network exception occurs during the connection of the host.
RETRYDURATION Retry within a specified period Specifies to add a host to the blocklist after the number of connection retries within a specified period reaches the specified value. This strategy can be configured after you set the RETRYTIMES and DURATION parameters. The unit of DURATION is milliseconds. For example, (RETRYTIMES=3) (DURATION=100) specifies to add the host to the blocklist after three connection retries fail within 100 ms.

OceanBase Connector/J supports only one blocklist entry removal strategy, which corresponds to the REMOVE_STRATEGY sub-parameter. The following table describes the strategies.

Algorithm Feature Remarks
TIMEOUT Timeout strategy The default strategy, which specifies to remove a host from the blocklist after the specified timeout period, in milliseconds.

Examples of blocklist strategies

String url = "jdbc:oceanbase:loadbalance://@(NET_SERVICE_NAME=(DESCRIPTION=
  (OBLB=ON)                                                    
  (OBLB_RETRY_ALL_DOWNS=120)
  (OBLB_GROUP_STRATEGY=ROTATION)                               
  (OBLB_BLACKLIST=
      (
        REMOVE_STRATEGY=(
          (NAME=TIMEOUT)
          (TIMEOUT=100)
        )
      )                          
      (
        APPEND_STRATEGY =(
          (NAME=RETRYDURATION)
          (RETRYTIMES=3)
          (DURATION=100)
        )
      )
  )
  (ADDRESS_LIST=
     (OBLB_STRATEGY=SERVERAFFINITY)                          
     (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=port1)(WEIGHT=1))      
     (ADDRESS=(PROTOCOL=tcp)(HOST=host2)(PORT=port2)(WEIGHT=10))
  )    
  (ADDRESS_LIST=
     (OBLB_STRATEGY=RANDOM)
     (ADDRESS=(PROTOCOL=tcp)(HOST=host3)(port=port3))
     (ADDRESS=(PROTOCOL=tcp)(HOST=host4)(port=port4))
  )
  (ADDRESS_LIST=
     (OBLB_STRATEGY=ROTATION)
     (ADDRESS=(PROTOCOL=tcp)(HOST=host3)(port=port3))
     (ADDRESS=(PROTOCOL=tcp)(HOST=host4)(port=port4))
   )
   (CONNECT_DATA=(SERVICE_NAME=OBDATABASE))
))/OBDATABASE?rewriteBatchedStatements=true&allowSendParamTypes=true&prepStmtCacheSize=1000";
Connection = DriverManager.getConnection(url);

Related parameters

Parameter Description Default value Remarks
DESCRIPTION The description for the connection. DESCRIPTION=(). The description of the connection is contained in the parentheses "()". N/A
OBLB Specifies whether to enable load balancing. You can specify this parameter in DESCRIPTION or ADDRESS_LIST. OFF OceanBase Connector/J ignores this parameter because LoadBalance is enabled in the extended configuration information. Also, this parameter does not take effect if it is specified in ADDRESS_LIST. You must configure this parameter later.
LOAD_BALANCE Specifies whether to enable load balancing. You can specify this parameter in DESCRIPTION or ADDRESS_LIST. OFF This parameter is equivalent to OBLB.
OBLB_RETRY_ALL_DOWNS The number of retries to connect all hosts. This parameter is specified in DESCRIPTION. 120 This parameter is equivalent to retryAllDowns in the URL.
OBLB_STRATEGY The LoadBalance strategy. You can specify this parameter in DESCRIPTION or ADDRESS_LIST. RANDOM If you specify this parameter in DESCRIPTION, each host specified in ADDRESS_LIST will use the strategy. If you specify this parameter in ADDRESS_LIST, only the specified hosts will use the strategy and the strategy settings in DESCRIPTION are ignored.
LOAD_BALANCE_STRATEGY The LoadBalance strategy. You can specify this parameter in DESCRIPTION or ADDRESS_LIST. RANDOM This parameter is equivalent to OBLB_STRATEGY.
OBLB_GROUP_STRATEGY The strategy for the access among hosts specified in ADDRESS_LIST. ROTATION Only the ROTATION strategy is supported.
OBLB_BLACKLIST A parameter in DESCRIPTION. The parentheses "()" after OBLB_BLACKLIST contain REMOVE_STRATEGY and APPEND_STRATEGY, which are parameters about the blocklist. OBLB_BLACKLIST=(). The description of the blocklist is contained in the parentheses "()". If you do not specify OBLB_BLACKLIST, the strategies specified for REMOVE_STRATEGY and APPEND_STRATEGY are used.
REMOVE_STRATEGY A parameter of OBLB_BLACKLIST. REMOVE_STRATEGY specifies the strategy for removing a host from the blocklist. REMOVE_STRATEGY=(). These strategies are contained in the parentheses "()". If you do not specify REMOVE_STRATEGY, the default strategy TIMEOUT is used, which specifies to remove the host from the blocklist after a specified period.
APPEND_STRATEGY A parameter of OBLB_BLACKLIST. APPEND_STRATEGY specifies strategies for adding a host to the blocklist. APPEND_STRATEGY=(). These strategies are contained in the parentheses "()". If you do not specify APPEND_STRATEGY, the default strategy NORMAL is used, which specifies to add the host to the blocklist when its connection fails.
NAME A parameter in both APPEND_STRATEGY and REMOVE_STRATEGY. You can use this parameter to specify the names of APPEND_STRATEGY and REMOVE_STRATEGY. The value of NAME must be either one of the specified strings. Otherwise, an error is returned. The only name of REMOVE_STRATEGY is TIMEOUT. Supported names of APPEND_STRATEGY are RETRYDURATION and NORMAL.
TIMEOUT A parameter available when NAME in REMOVE_STRATEGY is TIMEOUT. It specifies the timeout period in milliseconds. 50 This parameter is equivalent to loadBalanceBlacklistTimeout in the URL.
RETRYTIMES One of the parameters available when NAME in APPEND_STRATEGY is RETRYDURATION. This parameter specifies the maximum number of retries within the period specified by DURATION. After the number of connection retries of a host exceeds the specified value, the host is added to the blocklist. You must use this parameter with DURATION.
DURATION One of the parameters available when NAME in APPEND_STRATEGY is RETRYDURATION. When the number of connection retries of a host exceeds the value of RETRYTIMES within the period specified by DURATION, the host is added to the blocklist. You must use this parameter with RETRYTIMES.
ADDRESS_LIST A parameter in DESCRIPTION. You can use this parameter to specify OBLB_STRATEGY for multiple groups of ADDRESS fields or a separate OBLB_STRATEGY. The load balancing strategy for multiple groups of hosts is specified by OBLB_GROUP_STRATEGY. ADDRESS_LIST=(). The description of an ADDRESS group is contained in the parentheses "()". N/A
ADDRESS A parameter in ADDRESS_LIST that specifies the host information, such as the hostname, port, and weight. ADDRESS=(). The description of an ADDRESS is contained in the parentheses "()". N/A
HOST A parameter in ADDRESS that specifies the name of the current host. N/A N/A
PORT A parameter in ADDRESS that specifies the port of the current host. N/A N/A
WEIGHT A parameter in ADDRESS that specifies the weight of the current host. N/A The weight is recognized only when OBLB_STRATEGY is set to SERVERAFFINITY.
PROTOCOL A parameter in ADDRESS that specifies the network protocol used by the current host. N/A At present, this parameter is provided only to be compatible with the configuration format of the Local Naming Parameters file of Oracle.
CONNECT_DATA The name of the database service to connect. N/A This parameter is provided only to be compatible with the configuration format of the Local Naming Parameters file of Oracle.
SERVICE_NAME The schema information. N/A This parameter is provided only to be compatible with the configuration format of the Local Naming Parameters file of Oracle.

Previous topic

Failover and load balancing modes
Last

Next topic

Load balancing strategy configuration methods
Next
What is on this page
Load balancing strategies
Load balancing group selection strategy
Blocklist strategies
Examples of blocklist strategies
Related parameters