Databases 8 min read

Diagnosing ORA-06502 "no data found" Errors When Accessing OceanBase LOBs via JDBC

This article explains why JDBC access to OceanBase (Oracle mode) LOB columns can trigger an ORA-06502 "no data found" error, analyzes the driver’s readFromServer implementation, and shows how disabling the useLobLocatorV2 option eliminates the exception.

Aikesheng Open Source Community
Aikesheng Open Source Community
Aikesheng Open Source Community
Diagnosing ORA-06502 "no data found" Errors When Accessing OceanBase LOBs via JDBC

When accessing LOB data in OceanBase (Oracle mode) through JDBC, developers often encounter an ORA-06502 numeric or value error stating "no data found" at DBMS_LOB.READ . The article walks through the root cause and the fix.

1. Fault Background

During a customer test, the following error was observed:

(conn=499974) ORA-06502: PL/SQL: numeric or value error: no data found at oceanbase.DBMS_LOB.READ , line : 162, col : 1

The task continued to run, but the transaction was marked as failed.

2. Environment and Versions

OceanBase (Oracle mode) 4.2.5

OceanBase‑Client 2.4.12

3. Investigation Process

Finding the Error SQL

Using gv$ob_sql_audit the offending SQL was located:

call DBMS_LOB.READ('666666F777',32767,15008,NULL);

Ret_code was -5677.

Analyzing OBServer Logs

The server log contained:

[errorcode=-5677] offset is larger than lob_len (ret=-5677, offset_len=15008, lob_len=15007)

The third parameter (offset) exceeded the actual LOB length.

Retrieving Session Context

By filtering the audit view with the session ID, the following business query was found:

select * from ACT_xxxxx WHERE xxxxx_ID = ? ORDER BY NAME_ ASC;

This query reads the BLOB column BYTES_ , whose stored size is 15007 bytes, matching the log error.

4. Cause Analysis

Who issued the CALL DBMS_LOB.READ?

The application code does not call CALL DBMS_LOB.READ directly. The OceanBase JDBC driver (source file com/oceanbase/jdbc/Blob.java ) does so via the readFromServer method when fetching LOB data.

Why is the offset 15008?

The driver reads the LOB in a loop, increasing the offset each iteration. The last iteration attempts to read beyond the actual length (15007), causing the "no data found" exception. This behavior is expected for the driver version.

How to Avoid the Error

OceanBase JDBC provides the option useLobLocatorV2 (default TRUE). When TRUE, the driver first returns a LOB locator and then calls readFromServer , which triggers the extra read. Setting useLobLocatorV2=false makes the driver return the data directly, eliminating the extra call and the error.

/* 1066 */   USE_LOB_LOCATOR_V2("useLobLocatorV2", Boolean.TRUE, "2.4.7", "Set to true to use lob v2, false to use the original lob", false),

Validation

In the customer environment, adding useLobLocatorV2=false to the JDBC options resolved the error.

5. Summary

The "no data found" error is a normal side‑effect of the default LOB fetching logic in OceanBase JDBC and does not affect actual data integrity. If the error messages are undesirable, disable the useLobLocatorV2 option.

Reference

[1] DBMS_LOB READ exception details: https://www.oceanbase.com/docs/enterprise-oceanbase-database-cn-10000000000886801

DatabaseJDBCOceanBaseDBMS_LOBLOB
Aikesheng Open Source Community
Written by

Aikesheng Open Source Community

The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.