Traditionally, this is a clue that the class cast on that next line is incorrect. You cast to oracle.sql.BLOB - what makes you think that's the correct class? It probably isn't, and that's why you get the error. Instead, look at the declared return type of getBlob: java.sql.Blob. This interface has the getBinaryStream() method - isn't that enough? I'm not sure why you need the Oracle-specific method getChunkSize(); you should be able to work without it. Isn't your goal to get all of the data, regardless of chunk size? Probably you can either put it all in a single byte array (sized using getLength()) or copy the stream to some other OutputStream - e.g. a FileOutputStream or a servlet response's OutputStream.