In PostgreSQL the bytea
type is not a BLOB, and you can’t use a stream. In SQL standard terms it is a byte string. It should be loaded to a byte array in Java.
If you want to use BLOB techniques in PostgreSQL you must use the large objects feature.
http://www.postgresql.org/docs/current/interactive/largeobjects.html