Here you can find the source of getDataFromBlob(Blob b)
public static byte[] getDataFromBlob(Blob b) throws Exception
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.sql.Blob; public class Main { public static byte[] getDataFromBlob(Blob b) throws Exception { ByteArrayOutputStream bout = new ByteArrayOutputStream(); InputStream in = b.getBinaryStream(); byte[] buffer = new byte[10240]; int len = 0; while ((len = in.read(buffer, 0, 10240)) != -1) { bout.write(buffer, 0, len);/*from w w w .j av a 2 s . c om*/ } bout.flush(); return bout.toByteArray(); } }