Reading a 3 GB BLOB with JDBC 11.2.0.1 Fails With "ORA-22925: operation would exceed maximum size allowed for a LOB value"

(Doc ID 1101087.1)

Last updated on OCTOBER 23, 2017

Applies to:

JDBC - Version 11.2.0.1.0 to 11.2.0.2.0 [Release 11.2]
Oracle Database - Standard Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]
Information in this document applies to any platform.
Add ***Checked for relevance on 28-Feb-2013***



Symptoms

A java application reads BLOBs from a database and writes them to a file using the code:

while (resultSet.next()) {
   File lf = new File("C:\\temp\\LARGEFILE.bin");
   FileOutputStream fos = new FileOutputStream(lf);
   byte[] buffer = new byte[1024];
   InputStream is = resultSet.getBlob(1).getBinaryStream();
   while (is.read(buffer) > 0) {
      fos.write(buffer);
   }
fos.close();
}


When using JDBC 11.2.0.1 to read a 3 GB BLOB, the application writes only 2097166 KB to the file and fails with:

java.io.IOException: ORA-22925: operation would exceed maximum size allowed for a LOB value

     at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:204)
     at oracle.jdbc.driver.OracleBufferedStream.readInternal(OracleBufferedStream.java:174)
     at oracle.jdbc.driver.OracleBufferedStream.read(OracleBufferedStream.java:143)
     at oracle.jdbc.driver.OracleBufferedStream.read(OracleBufferedStream.java:132)
     at BigBlobs.main(BigBlobs.java:41)
Caused by: java.sql.SQLException: ORA-22925: operation would exceed maximum size allowed for a LOB value

     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:388)
     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:381)
     at oracle.jdbc.driver.T4C8TTILob.processError(T4C8TTILob.java:789)
     at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
     at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
     at oracle.jdbc.driver.T4C8TTILob.read(T4C8TTILob.java:146)
     at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2313)
     at oracle.sql.BLOB.getBytes(BLOB.java:319)
     at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:181)
     ... 4 more


When using JDBC 11.2.0.1 to read a 4 GB or larger BLOB from a 10.2.0.3 database, the ORA-22925 error also occurs.

However, when using JDBC 11.2.0.1 to read a 4 GB or larger BLOB from an 11.1.0.6 database, the output is truncated without an error. See <Note 1101163.1> Silent (No Error) Truncation Reading a 4 GB or Larger BLOB with JDBC 11.2.0.1 for details.

When using JDBC 11.1.0.7 to read the same 3GB, 4GB and larger BLOBs, the ORA-22925 does not occur. Nor does truncation occur.

Changes

The ORA-22925 occurred after upgrading JDBC 11.1.0.7 to JDBC 11.2.0.1.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms