code: public InputStream getBinaryStream(final long pos, final long length) throws SQLException {
      if (pos < 1) {
        throw ExceptionMapper.getSqlException("Out of range (position should be > 0)");
      }
      if (pos - 1 > this.length) {
        throw ExceptionMapper.getSqlException("Out of range (position > stream size)");
      }
      if (pos + length - 1 > this.length) {
        throw ExceptionMapper.getSqlException("Out of range (position + length - 1 > streamSize)");
      }
  
      return new ByteArrayInputStream(data, this.offset + (int) pos - 1, (int) length);
    }
docs: Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value,
  starting  with the byte specified by pos, which is length bytes in length.
  
  @param pos    the offset to the first byte of the partial value to be retrieved. The first byte
  in the
  <code>Blob</code> is at position 1
  @param length the length in bytes of the partial value to be retrieved
  @return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
  @throws SQLException if pos is less than 1 or if pos is greater than the number of bytes in
  the
  <code>Blob</code> or if pos + length is greater than the number of bytes
  in the
  <code>Blob</code>