protected void writeBlob(int testId,byte[] testBytes,FbDatabase db,BlobParameterBuffer blobParameterBuffer) throws SQLException {
  final SimpleStatementListener listener=new SimpleStatementListener();
  final FbTransaction transaction=getTransaction(db);
  try {
    final FbStatement statement=db.createStatement(transaction);
    statement.addStatementListener(listener);
    final FbBlob blob=db.createBlobForOutput(transaction,blobParameterBuffer);
    blob.open();
    int bytesWritten=0;
    while (bytesWritten < testBytes.length) {
      byte[] buffer=new byte[Math.min(blob.getMaximumSegmentSize(),testBytes.length - bytesWritten)];
      System.arraycopy(testBytes,bytesWritten,buffer,0,buffer.length);
      blob.putSegment(buffer);
      bytesWritten+=buffer.length;
    }
    blob.close();
    statement.prepare(INSERT_BLOB_TABLE);
    final DatatypeCoder datatypeCoder=db.getDatatypeCoder();
    FieldValue param1=new FieldValue(datatypeCoder.encodeInt(testId));
    FieldValue param2=new FieldValue(datatypeCoder.encodeLong(blob.getBlobId()));
    statement.execute(RowValue.of(param1,param2));
    statement.close();
  }
  finally {
    transaction.commit();
  }
}

protected void writeBlob ( int testId , byte [ ] testBytes , FbDatabase db , BlobParameterBuffer blobParameterBuffer ) throws SQLException { final SimpleStatementListener listener = new SimpleStatementListener ( ) ; final FbTransaction transaction = getTransaction ( db ) ; try { final FbStatement statement = db . createStatement ( transaction ) ; statement . addStatementListener ( listener ) ; final FbBlob blob = db . createBlobForOutput ( transaction , blobParameterBuffer ) ; blob . open ( ) ; int bytesWritten = 0 ; while ( bytesWritten < testBytes . length ) { byte [ ] buffer = new byte [ Math . min ( blob . getMaximumSegmentSize ( ) , testBytes . length - bytesWritten ) ] ; System . arraycopy ( testBytes , bytesWritten , buffer , 0 , buffer . length ) ; blob . putSegment ( buffer ) ; bytesWritten += buffer . length ; } blob . close ( ) ; statement . prepare ( INSERT_BLOB_TABLE ) ; final DatatypeCoder datatypeCoder = db . getDatatypeCoder ( ) ; FieldValue param1 = new FieldValue ( datatypeCoder . encodeInt ( testId ) ) ; FieldValue param2 = new FieldValue ( datatypeCoder . encodeLong ( blob . getBlobId ( ) ) ) ; statement . execute ( RowValue . of ( param1 , param2 ) ) ; statement . close ( ) ; } finally { transaction . commit ( ) ; } }
writes a blob using the gds . ng api .
