What is the difference between resultSet.getBinaryStream() and resultSet.GetBlob().getBinaryStream() for ojdbc

Viewed 39

What is the difference between resultSet.getBinaryStream() and resultSet.GetBlob().getBinaryStream() for ojdbc? Both methods return an OracleBlobInputStream, but resultSet.getBinaryStream() will set an "internalBlob" flag to true in the stream object while getBlob().getBinaryStream() will set it to false. I noticed the difference when closing the stream itself. If the flag is true the close() method will attempt to "free" the Blob object. This adds pretty significant overhead to the closing process (about .05s in my tests) which adds up when pulling many blobs from the db. The problem is solved when using getBlob().getBinarySTream() as the flag is false and the blob object is not freed. I was just hoping anyone would be able to shed light on what the internalBlob flag is actually for, and if it matters whether the blob is freed or not.

Here is the close() method inside the OracleBlobInputStream

public void close() throws IOException {
    if (!this.closed) {
        try {
            if (this.blob != null && this.internalBlob) {
                this.blob.free();
                this.internalBlob = false;
            }
        } catch (SQLException var5) {
            throw (IOException)((IOException)DatabaseError.createIOException(var5).fillInStackTrace());
        } finally {
            super.close();
        }
    }
}
0 Answers
Related