Code example for Blob

Methods: getBytes, length

0
            if (rs.next()) {
                image.setId(rs.getInt("did"));
                image.setContentType(rs.getString("phototype"));
                Blob blob = rs.getBlob("photodata");
                if (blob!=null) {
                    int blobSize = (int)blob.length();
                    byte[] outData = new byte[blobSize];
                    System.arraycopy(blob.getBytes(1, blobSize), 0, outData, 0, blobSize);
                    image.setImgData(outData);
                } 
            } 
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            closeConnection(); 
            return image;
        } 
    } 
     
}