1) available() does not guarantee to return the size of the blob. Blob.length() should be used. Also, the length should be a long. 2) InputStream.read(byte) does not guarantee to read all the bytes requested. 3) The SQL selects all the rows but only the first is processed. 4) If stmt.close() throws an exception then the connection is never closed.