code: private static byte[] toBytes(Blob b) {
          try {
              InputStream is = b.getBinaryStream();
              byte[] result = IOUtils.toByteArray(is);
              is.close();
              b.free();
              return result;
          } catch (IOException e) {
              throw new RuntimeException(e);
          } catch (SQLException e) {
              throw new SQLRuntimeException(e);
          }
  
      }
docs: Returns the bytes of a {@link Blob} and frees the blob resource.
  
  @param b
  blob
  @return