I'm trying to write a servlet to read and serve
images stored in a table as blob.
I've an instance of PG 7.3 on a redhat 7.3 box
with a DB created using the ENCODING='LATIN1' option.
My servlet runs in tomcat4.1.24+j2sdk1.4.1_02 environment
with the pg73jdbc2.jar library installed.
I've tried to store my jpeg image in a TEXT field and in an OID field
(and I can see it with a win32 client)
but using this code (that's OK with mysql)
...
BufferedInputStream blobBIS =
new BufferedInputStream(rs.getBinaryStream("image_blob));
byte[] buf = new byte[4 * 1024]; // 4K buffer
int len;
ServletOutputStream binout = response.getOutputStream();
while ((len = blobBIS.read(buf, 0, buf.length)) != -1)
binout.write(buf, 0, len);
blobBIS.close();
binout.close();
...
the stream closes after a few (6/7) bytes.
What's wrong?
Thanks a lot.
Alessandro
alessandro.pellegrini@infoblu.it