OceanBase logo

OceanBase

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

Product Overview
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

OceanBase

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

Product Overview
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.2.3

  • What is OceanBase Connector J?
    • JDBC overview
    • Compatibility requirements
  • Instructions
    • Install OceanBase Client
    • Basic operations
      • Import packages
      • Create a database connection
      • Create a Statement object
      • Run queries and retrieve ResultSet objects
      • Process a ResultSet object
      • Close ResultSet and Statement objects
      • Modify a database
      • Commit changes
      • Close a database connection
    • Handle SQL exceptions
    • Java data streams
      • Overview of Java data streams
      • LONG and LONG RAW data types
      • LOB data types
    • Use LOBs
      • Overview of LOB data types
      • LOB data API
      • LOB locator API
      • CHAR, VARCHAR, and RAW data types
    • Use CallableStatements to call stored procedures
    • Data sources and URL
      • Data source overview
      • Data source characteristics and properties
      • Create and connect to a data source instance
      • Database URL
    • Result set
      • Limits and degradation rules
      • Fetch size
      • Refetch rows
      • Cursor result sets
    • Statement caching
      • Statement caching overview
      • Use statement cache
      • Reuse statement objects
    • Failover and load balancing modes
    • Batch processing
    • JDBC security features
    • SQL NetworkCostInfo
    • Troubleshooting
    • Common APIs
      • 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
    • Reference
      • Supported SQL and PL data types
  • Features specific to the Oracle mode
    • Call PL stored procedures
    • Result set performance
    • Use ARRAY and STRUCT classes
    • Distributed transactions
      • Overview of distributed transactions
      • XA components
      • Distributed transaction examples
    • Error messages in Oracle mode
    • Data types supported in Oracle mode

Download PDF

JDBC overview Compatibility requirements Install OceanBase Client Import packages Create a database connection Create a Statement object Run queries and retrieve ResultSet objects Process a ResultSet object Close ResultSet and Statement objects Modify a database Commit changes Close a database connection Handle SQL exceptions Overview of Java data streams LONG and LONG RAW data types LOB data types Overview of LOB data types LOB data API LOB locator API CHAR, VARCHAR, and RAW data types Use CallableStatements to call stored procedures Data source overview Data source characteristics and properties Create and connect to a data source instance Database URL Limits and degradation rules Fetch size Refetch rows Cursor result sets Statement caching overview Use statement cache Reuse statement objects Failover and load balancing modesBatch processing JDBC security features SQL NetworkCostInfo Troubleshooting 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 Supported SQL and PL data types Call PL stored procedures Result set performance Use ARRAY and STRUCT classes Overview of distributed transactions XA components Distributed transaction examples Error messages in Oracle mode Data types supported in Oracle mode
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.2.3
iconOceanBase Connector/J
V 2.2.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

LOB data API

Last Updated:2026-04-09 07:36:39  Updated
share
What is on this page
Input
Output
CallableSatement and IN OUT parameters
Size limit

folded

share

The OceanBase JDBC driver (OceanBase Client) provides a data API, which is a simplified mechanism for writing and reading the content of the entire LOB.

The data API uses the standard JDBC methods (such as getString and setBytes) to read and write LOB data. The data API simplifies coding and accelerates data access. However, unlike the standard java.sql.Blob, java.sql.Clob, and java.sql.NClob APIs, the data API does not support random access, and the volume of accessed data cannot exceed 2,147,483,648 elements.

Input

The OceanBase JDBC driver extends the setBytes, setBinaryStream, setString, setCharacterStream, and setAsciiStream methods of PreparedStatement, to enhance the capability of using BLOBs, CLOBs, and NCLOBs.

The maximum length of an SQL statement (for example, the INSERT statement) executed by the internal driver of the server is 4,000 bytes. This limit does not apply to PL statements. To bypass this limit, you can encapsulate the INSERT statement into a PL block by using the following method:

BEGIN
 INSERT id, name INTO clob_emp VALUES(?,?);
END

Three input modes are available for large-scale data:

  • Direct binding

    The binding size in this mode is limited, but the input efficiency is the highest. The data in all input columns is concatenated in a data block and then sent to the server. All data, including data involved in multiple executions of batch processing, is sent in a single network operation.

  • Stream binding

    The data is put at the end. Only one stream is sent at a time. Therefore, multiple round trips may be required.

  • LOB binding

    A temporary LOB is created. The data is copied to the LOB and bound to LOB locators. The temporary LOB is automatically released after execution. Multiple round trips are required for creating the temporary LOB and writing data to the LOB. The locators can be specified in batches.

Take note of the following instructions on the input modes for SQL statements:

  • The setBytes and setBinaryStream methods use direct binding for data less than 4001 bytes.

  • The setBytes and setBinaryStream methods use stream binding is used for data greater than 4000 bytes.

  • The setAsciiStream, setBinaryStream, and setCharacterStream methods take a long argument as the form length and uses LOB binding for forms whose lengths are larger than 2,147,483,648. LOB binding is always used for forms where the length is not specified.

  • The setString, setCharacterStream, and setAsciiStream methods use direct binding used for data smaller than 32,767 characters.

  • The setString, setCharacterStream, and setAsciiStream methods use stream binding for data larger than 32,766 characters.

  • The new form of the setCharacterStream method takes a long argument for length and uses LOB binding for length larger than 2147483647. LOB binding is always used for forms where the length is not specified.

Take note of the following instructions on the input modes for PL statements:

  • The setBytes and setBinaryStream methods use direct binding for data smaller than 32,767 bytes.

  • The setBytes and setBinaryStream methods use LOB binding for data larger than 32,766 bytes.

  • The setString, setCharacterStream, and setAsciiStream methods use direct binding for data smaller than 32,767 bytes in the database character set.

    Note

    The setString method is not applicable to BLOBs.

  • The setString, setCharacterStream, and setAsciiStream methods use LOB binding for data larger than 32,766 bytes in the database character set.

Automatic switching of input modes affects some programs. Automatic switching may also result in additional parsing by the server, to cope with changes of parameter types. If the data size is changing around the threshold when a statement is repeatedly executed, the performance is affected. Switching to the stream binding mode affects batch processing.

Output

The getBytes, getBinaryStream, getString, getCharacterStream, and getAsciiStream methods of the ResultSet and CallableStatement operations are extended to be used with BLOBs, CLOBs, or OUT parameters. These methods are applicable to any LOBs whose lengths are smaller than 2,147,483,648. Note

The getString and getNString methods cannot be used to retrieve the column values of BLOBs.

The data API accesses the LOB locators in the driver to perform operations without programming. You can enable LOB prefetch as needed to reduce or eliminate other database round trips.

You can read and write BLOB or CLOB data in the same streaming transmission mechanism as LONG RAW and LONG data. You can use the defineColumnType(nn,Types.LONGVARBINARY) or defineColumnType(nn,Types.LONGVARCH method on columns to read data and generate direct streams, which is similar to reading data from the LONG RAW or LONG columns.

CallableSatement and IN OUT parameters

PL requires that the same Java types be used for input and output of IN OUT parameters.

The IN OUT CLOB parameter of a stored procedure is expected to be set by using the setString method. The same types of IN and OUT parameters must be bound. If you are not sure about the data size, automatic switching of input modes will cause errors. For example, if you have learned that neither the input data nor the output data is larger than 32,766 bytes, you can use the setString method for input parameters, and register OUT parameters as Types.VARCHAR and use the getString method for output parameters.

A better solution is to modify the stored procedure to have separate IN and OUT parameters. Example (original):

CREATE PROCEDURE clob_obproc( cc IN OUT CLOB );

Example (modified):

CREATE PROCEDURE clob_obproc( cc_in IN CLOB, cc_out OUT CLOB );

Another solution is to use container blocks for calls. The clob_plproc stored procedure can be wrapped with Java strings for prepareCall statements:

"DECLARE cc_temp; BEGIN cc_temp := ?; clob_plproc( cc_temp); ? := cc_temp; END;"

In either solution, the setString method can be used for the first parameter, and the registerOutParameter method and Types.CLOB can be used for the second parameter.

Size limit

If you create a very large byte array or string, the performance of your Java memory management system may be affected. Read the information provided by the Java virtual machine (JVM) supplier about the impact of massive amounts of data elements on memory management, and try using a streaming API.

Previous topic

Overview of LOB data types
Last

Next topic

LOB locator API
Next
What is on this page
Input
Output
CallableSatement and IN OUT parameters
Size limit