code: public static <T, E extends Exception> long importData(final Iterator<T> iter, long offset, final long count, final Try.Predicate<? super T, E> filter,
              final PreparedStatement stmt, final int batchSize, final int batchInterval,
              final Try.BiConsumer<? super PreparedStatement, ? super T, SQLException> stmtSetter) throws UncheckedSQLException, E {
          N.checkArgument(offset >= 0 && count >= 0, "'offset'=%s and 'count'=%s can't be negative", offset, count);
          N.checkArgument(batchSize > 0 && batchInterval >= 0, "'batchSize'=%s must be greater than 0 and 'batchInterval'=%s can't be negative", batchSize,
                  batchInterval);
  
          long result = 0;
  
          try {
              while (offset-- > 0 && iter.hasNext()) {
                  iter.next();
              }
              T next = null;
              while (result < count && iter.hasNext()) {
                  next = iter.next();
  
                  if (filter != null && filter.test(next) == false) {
                      continue;
                  }
  
                  stmtSetter.accept(stmt, next);
                  stmt.addBatch();
  
                  if ((++result % batchSize) == 0) {
                      stmt.executeBatch();
                      stmt.clearBatch();
  
                      if (batchInterval > 0) {
                          N.sleep(batchInterval);
                      }
                  }
              }
  
              if ((result % batchSize) > 0) {
                  stmt.executeBatch();
                  stmt.clearBatch();
              }
          } catch (SQLException e) {
              throw new UncheckedSQLException(e);
          }
  
          return result;
      }
docs: Imports the data from Iterator to database.
  
  @param iter
  @param offset
  @param count
  @param filter
  @param stmt
  @param batchSize
  @param batchInterval
  @param stmtSetter
  @return
  @throws UncheckedSQLException