title: java.util.stream with ResultSet
body: <p>I have few tables with big amount of data (about 100 million records). So I can't store this data in memory but I would like to stream this <strong>result set</strong> using <code>java.util.stream</code> class and pass this stream to another class. I read about <code>Stream.of</code> and <code>Stream.Builder</code> operators but they are buffered streams in memory. So is there any way to resolve this question? 
  Thanks in advance.</p>
  
  <p><strong>UPDATE #1</strong></p>
  
  <p>Okay I googled and found <strong>jooq</strong> library. I'm not sure but looks like it could be applicable to my test case. To summarize I have few tables with big amount of data. I would like to stream my resultset and transfer this stream to another method. Something like this:</p>
  
  <pre><code>// why return Stream&lt;String&gt;? Because my result set has String type
  private Stream&lt;Record&gt; writeTableToStream(DataSource dataSource, String table) {
  
      Stream&lt;Record&gt; record = null;
      try (Connection connection = dataSource.getConnection()) {
          String sql = "select * from " + table;
  
          try (PreparedStatement pSt = connection.prepareStatement(sql)) {
              connection.setAutoCommit(false);
              pSt.setFetchSize(5000);
              ResultSet resultSet = pSt.executeQuery();
              //
              record = DSL.using(connection)
                      .fetch(resultSet).stream();
          }
      } catch (SQLException sqlEx) {
          logger.error(sqlEx);
      }
  
      return record;
  }
  </code></pre>
  
  <p>Could please someone advise, am I on correct way? Thanks.</p>
  
  <p><strong>UPDATE #2</strong></p>
  
  <p>I made some experiment on <strong>jooq</strong> and could say now that above decision is not suitable for me. This code <code>record = DSL.using(connection).fetch(resultSet).stream();</code> takes too much time </p>