Here you can find the source of toByteArray(Blob blob)
private static byte[] toByteArray(Blob blob)
//package com.java2s; /*// www . j a va 2 s . com * Hibernate, Relational Persistence for Idiomatic Java * * License: GNU Lesser General Public License (LGPL), version 2.1 or later. * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. */ import java.sql.Blob; import java.sql.SQLException; public class Main { private static byte[] toByteArray(Blob blob) { try { return blob.getBytes(1, (int) blob.length()); } catch (SQLException e) { throw new RuntimeException( "Error on transforming blob into array.", e); } } }