public static String importResultSet(ResultSet source,Database db,String name,ImportFilter filter,boolean useExistingTable) throws SQLException, IOException {
  ResultSetMetaData md=source.getMetaData();
  name=TableBuilder.escapeIdentifier(name);
  Table table=null;
  if (!useExistingTable || ((table=db.getTable(name)) == null)) {
    List<ColumnBuilder> columns=toColumns(md);
    table=createUniqueTable(db,name,columns,md,filter);
  }
  List<Object[]> rows=new ArrayList<Object[]>(COPY_TABLE_BATCH_SIZE);
  int numColumns=md.getColumnCount();
  while (source.next()) {
    Object[] row=new Object[numColumns];
    for (int i=0; i < row.length; i++) {
      row[i]=source.getObject(i + 1);
    }
    row=filter.filterRow(row);
    if (row == null) {
      continue;
    }
    rows.add(row);
    if (rows.size() == COPY_TABLE_BATCH_SIZE) {
      table.addRows(rows);
      rows.clear();
    }
  }
  if (rows.size() > 0) {
    table.addRows(rows);
  }
  return table.getName();
}

public static String importResultSet ( ResultSet source , Database db , String name , ImportFilter filter , boolean useExistingTable ) throws SQLException , IOException { ResultSetMetaData md = source . getMetaData ( ) ; name = TableBuilder . escapeIdentifier ( name ) ; Table table = null ; if ( ! useExistingTable || ( ( table = db . getTable ( name ) ) == null ) ) { List < ColumnBuilder > columns = toColumns ( md ) ; table = createUniqueTable ( db , name , columns , md , filter ) ; } List < Object [ ] > rows = new ArrayList < Object [ ] > ( COPY_TABLE_BATCH_SIZE ) ; int numColumns = md . getColumnCount ( ) ; while ( source . next ( ) ) { Object [ ] row = new Object [ numColumns ] ; for ( int i = 0 ; i < row . length ; i ++ ) { row [ i ] = source . getObject ( i + 1 ) ; } row = filter . filterRow ( row ) ; if ( row == null ) { continue ; } rows . add ( row ) ; if ( rows . size ( ) == COPY_TABLE_BATCH_SIZE ) { table . addRows ( rows ) ; rows . clear ( ) ; } } if ( rows . size ( ) > 0 ) { table . addRows ( rows ) ; } return table . getName ( ) ; }
copy an existing jdbc resultset into a new ( or optionally existing ) table in this database .
