Preparedstatement.Setbinarystream() Does Not Read All The Data From The Stream
Last updated on MARCH 08, 2017
Applies to:JDBC - Version 10.2.0.1 to 188.8.131.52 [Release 10.2 to 11.2]
Information in this document applies to any platform.
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 InputStream.read()
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