I have these four different ways by which I am inserting some file data into an Oracle database using JDBC and PreparedStatements.
Blob blob = ps.getConnection().createBlob(); blob.setBytes(1, fileDataInByteArray); ps.setBlob(1, blob);
In general, Approach C & D seem to be very useful for large fileData. A & B can run out of memory, but obviously C & D are more reliable.
However, when the file size is smaller the danger of OOM is not there. I find that A & B take less time for the database insert. I suppose that’s because when the data is a byteArray, it’s much faster.
What can I do to speed up the insert when using C&D?
I have tried wrapping the input stream with a BufferedInputSteam. I played around with the buffer size. But that did not help.
Are we at the mercy of how fast Oracle can read the data? Can that be speeded up?