Preparedstatement.Setbinarystream() Does Not Read All The Data From The Stream

(Doc ID 1091238.1)

Last updated on MARCH 08, 2017

Applies to:

JDBC - Version to [Release 10.2 to 11.2]
Information in this document applies to any platform.


PreparedStatement.setBinaryStream() does not read all the bytes in the stream. Consequently only partial data is stored in the database.
The issue is in the JDBC driver which does not read the stream until end of file or even the length supplied. It reads as long as its buffer is filled, which is not guaranteed by the contract of
Supplying an InputStream that always fills the buffer does work correctly. Using setBytes() does work because it supplies all the content right away, however this will not work with streams that are too large to be loaded into a byte array in memory.
The end result is that you may find that the BLOB stored in the database is smaller than the size of the stream used by the PreparedStatement.setBinaryStream().


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