简体   繁体   中英

How to retrieve a Long from Oracle using java

I have a database where a Long datatype has an image stored in it, I want to retrieve it and write it to an image file,

I tried using getBytes method and write a file using for and it return as corrupt image,

I also tried using getBinarystream and write using fos I wrote it in an image file I get same corrupt error.

Code:

InputStream is = RS.getBinaryStream(1);
FileOutputStream fos = new FileOutputStream ("image.bmp");
Int c;
While((c=is.read())!=-1)
{
fos.write(c);
}
fos.close;

To store binary data you should use LONG_RAW or a BLOB. The type LONG is for character based (text) data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM