public synchronized int readFromFile(JDBCSequentialFile file,ByteBuffer bytes) throws SQLException {
  connection.setAutoCommit(false);
  readLargeObject.setInt(1,file.getId());
  int readLength=0;
  try (ResultSet rs=readLargeObject.executeQuery()){
    if (rs.next()) {
      Blob blob=rs.getBlob(1);
      readLength=(int)calculateReadLength(blob.length(),bytes.remaining(),file.position());
      byte[] data=blob.getBytes(file.position() + 1,readLength);
      bytes.put(data);
    }
    connection.commit();
    return readLength;
  }
 catch (  Throwable e) {
    connection.rollback();
    throw e;
  }
}

public synchronized int readFromFile ( JDBCSequentialFile file , ByteBuffer bytes ) throws SQLException { connection . setAutoCommit ( false ) ; readLargeObject . setInt ( 1 , file . getId ( ) ) ; int readLength = 0 ; try ( ResultSet rs = readLargeObject . executeQuery ( ) ) { if ( rs . next ( ) ) { Blob blob = rs . getBlob ( 1 ) ; readLength = ( int ) calculateReadLength ( blob . length ( ) , bytes . remaining ( ) , file . position ( ) ) ; byte [ ] data = blob . getBytes ( file . position ( ) + 1 , readLength ) ; bytes . put ( data ) ; } connection . commit ( ) ; return readLength ; } catch ( Throwable e ) { connection . rollback ( ) ; throw e ; } }
reads data from the file ( at file . readposition ) into the bytebuffer .
