0

Good day sir, I'm having trouble in deploying image from database with a blob datatype. I tried path and it's working good. Now I want to try out Blob but I'm having trouble what code will I use. thanks in advance sir

database image value .

here's the code.

List<rec_item_med> recitemmed = new rec_item_med().findAll();

for (rec_item_med l : recitemmed){
    File file = new File("C:\\ecommerce\\first_ecom\\webcontent\\images\\items\\"+l.getString("No")+".png");
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    byte[] bytes = l.getBytes("picture");
    InputStream inputStream = new ByteArrayInputStream(bytes);

    byte[] b = new byte[1024];
    while (inputStream.read(b) > 0) {
        fileOutputStream.write(b);
    }
}
ipolevoy
  • 5,432
  • 2
  • 31
  • 46
Kuya
  • 28
  • 11

0 Answers0