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.3

  • 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 of LOB data types
        • 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 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
    • Security features
    • Rich client
    • Network overheads
    • Show Trace
    • 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
  • Release
    • V2.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

Overview of OceanBase Connector/J Compatibility requirements Install and load the OceanBase Connector/J driver 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 source overviewDatabase URL Overview of Java data streams LONG and LONG RAW data types CHAR, VARCHAR, and RAW data types Overview of statement caching Use statement caching Reuse statement objects Call a stored procedure Handle SQL exceptions Overview of result sets Limitations FetchSize refreshRow useCursorFetch Batch processing Failover and load balancing modes LoadBalance strategies Load balancing strategy configuration methods Security features Rich client Network overheads Show Trace Troubleshooting Call PL stored procedures Scrollability of a result set Use ARRAY and STRUCT classes Obtain comments Data types supported in Oracle mode Error messages in Oracle mode Supported SQL and PL data types 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 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.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
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.3
iconOceanBase Connector/J
V 2.4.3
  • 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-09 07:21:44  Updated
share
What is on this page
Load balancing strategies
Load balancing group selection strategy
Blacklist strategies
Examples of blacklist strategies
Related parameters

folded

share

The LoadBalance mode of OceanBase Connector/J is used to create a connection for each connection object. Each time a connection object is created, a host is selected from the host list by using the load balancing policy to create a connection. Profile-based LoadBalance can monitor the corresponding configuration file directory and realize it after updating the configuration file. You can update the load balancing policy, host list, and other information without modifying the URL each time you execute getConnection.

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 URL Option. The following table describes the valid values of the parameters.

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 Rotation load balancing

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 valid values of the parameters.

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

Blacklist strategies

OceanBase Connector/J allows you to specify blacklist strategies by setting the following two sub-parameters of the OBLB_BLACKLIST parameter. The blacklist entry removal strategy can be configured by setting the REMOVE_STRATEGY sub-parameter. The blacklist entry adding strategies can be configured by setting the APPEND_STRATEGY sub-parameter.

OceanBase Connector/J supports two blacklist entry adding strategies, which correspond to the APPEND_STRATEGY sub-parameter. The following table describes the valid values of the parameters.

Algorithm Feature Remarks
NORMAL Normal strategy The default strategy, which specifies to add a host to the blacklist when a network exception occurs during the connection of the host.
RETRYDURATION Retry within a specified period Specifies to add a host to the blacklist 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. Example: (RETRYTIMES=3) (DURATION=100) specifies to add the host to the blacklist after the third connection retry fails within 100 ms.

OceanBase Connector/J supports only one blacklist removal strategy, which corresponds to the REMOVE_STRATEGY sub-parameter. The following table describes the valid values of the parameters.

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

Examples of blacklist 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 the retryAllDowns in URL Option.
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 blacklist. OBLB_BLACKLIST=(). The description of the blacklist 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 blacklist. These strategies are contained in the parentheses "()". If you do not specify REMOVE_STRATEGY, the default value of TIMEOUT is used, which specifies to remove the host from the blacklist after a specified period.
APPEND_STRATEGY A parameter of OBLB_BLACKLIST. APPEND_STRATEGY specifies strategies for adding a host from the blacklist. These strategies are contained in the parentheses "()". If you do not specify APPEND_STRATEGY, the default NORMAL strategy is used, which specifies to add the host to the blacklist 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 An option available when NAME in REMOVE_STRATEGY is TIMEOUT. TIMEOUT= specifies the timeout period in milliseconds. Default value: 50. This parameter is equivalent to loadBalanceBlacklistTimeout in URL Option.
RETRYTIMES One of the parameters of APPEND_STRATEGY when the value of NAME 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 blacklist. You must use this parameter with DURATION.
DURATION One of the parameters of APPEND_STRATEGY when the value of NAME 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 blacklist. 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 Specifies 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
Blacklist strategies
Examples of blacklist strategies
Related parameters