EOFException from getBinaryStream

If you get EOFException from a call to getBinaryStream on a result set, here are two suggestions:

  • Check that when you write the stream, you aren’t trying to read from the same stream twice. For example, you might try to update a row first, and if that returns 0 rows changed, then you may be trying to do an insert using the same stream that you read from for the update. This won’t work because once the stream is read once, the stream pointer is at the end of the content when you try to read the second time.
  • Try deserializing the stream right after serializing and without putting it into a file or dbms.  If this doesn’t work, it’s likely that your object type doesn’t implement Serializable nor Externalizable.
Print Friendly, PDF & Email