SQLResultSet implements IPentahoResultSet, IPeekable { public IPentahoResultSet memoryCopy() { try { MemoryResultSet cachedResultSet = new MemoryResultSet( getMetaData() ); Object[] rowObjects = next(); while ( rowObjects != null ) { cachedResultSet.addRow( rowObjects ); rowObjects = next(); } return cachedResultSet; } finally { close(); } } SQLResultSet( final ResultSet nativeResultSet, final SQLConnection nativeConnection ); void setMetaData( final IPentahoMetaData metadata ); IPentahoMetaData getMetaData(); Object[] peek(); Object[] next(); void closeConnection(); void close(); void dispose(); boolean isScrollable(); int getColumnCount(); int getRowCount(); Object getValueAt( final int row, final int column ); IPentahoResultSet memoryCopy(); void beforeFirst(); Object[] getDataColumn( final int column ); Object[] getDataRow( final int row );  }
@Test public void testMemoryCopy() throws SQLException { SQLResultSet resultSet = new SQLResultSet( nativeResultSet, nativeConnection ); IPentahoResultSet memoryCopyResultSet = resultSet.memoryCopy(); assertEquals( columns[0].length, memoryCopyResultSet.getColumnCount() ); assertTrue( Arrays.equals( columns[0], memoryCopyResultSet.getMetaData().getColumnHeaders()[0] ) ); verify( nativeResultSet, times( 1 ) ).close(); }