code: public static long exportCSV(final File out, final PreparedStatement stmt, final Collection<String> selectColumnNames, final long offset, final long count,
              final boolean writeTitle, final boolean quoted) throws UncheckedSQLException, UncheckedIOException {
          ResultSet rs = null;
  
          try {
              rs = stmt.executeQuery();
              // rs.setFetchSize(200);
  
              return exportCSV(out, rs, selectColumnNames, offset, count, writeTitle, quoted);
          } catch (SQLException e) {
              throw new UncheckedSQLException(e);
          } finally {
              JdbcUtil.closeQuietly(rs);
          }
      }
docs: Exports the data from database to CVS.
  
  @param out
  @param stmt
  @param selectColumnNames
  @param offset
  @param count
  @param writeTitle
  @param quoted
  @return