Preparedstatement.Setbinarystream() Does Not Read All The Data From The Stream
(Doc ID 1091238.1)
Last updated on AUGUST 09, 2023
Applies to:
JDBC - Version 10.2.0.1 to 11.2.0.1.0 [Release 10.2 to 11.2]Information in this document applies to any platform.
Symptoms
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 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().
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Cause |
Solution |
References |