Class StreamingQueryRunner


  • public class StreamingQueryRunner
    extends org.apache.commons.dbutils.QueryRunner
    An extension of the Apache DbUtils QueryRunner that adds methods to produce Streams where each element of the stream is constructed from a row in a ResultSet. This takes advantage of database cursors (assuming the underlying JDBC ResultSet does) so the entire query result does not have to be read into memory.
    • Field Summary

      • Fields inherited from class org.apache.commons.dbutils.AbstractQueryRunner

        ds
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> Stream<T> queryStream​(String sql, StreamingResultSetHandler<T> handler, Object... args)
      Executes a Query and returns a Stream in which each element represents a row in the result.
      Stream<Object[]> queryStream​(String sql, Object... args)  
      <T> Stream<T> queryStream​(Connection connection, String sql, StreamingResultSetHandler<T> handler, Object... args)
      Executes a Query and returns a Stream in which each element represents a row in the result.
      String toString()  
      • Methods inherited from class org.apache.commons.dbutils.QueryRunner

        batch, batch, execute, execute, execute, execute, insert, insert, insert, insert, insertBatch, insertBatch, query, query, query, query, query, query, query, query, update, update, update, update, update, update
      • Methods inherited from class org.apache.commons.dbutils.AbstractQueryRunner

        close, close, close, closeQuietly, closeQuietly, closeQuietly, fillStatement, fillStatement, fillStatementWithBean, fillStatementWithBean, getDataSource, getParameterMetaData, isPmdKnownBroken, prepareCall, prepareConnection, prepareStatement, prepareStatement, rethrow, wrap
    • Constructor Detail

      • StreamingQueryRunner

        public StreamingQueryRunner​(DataSource dataSource)
    • Method Detail

      • queryStream

        public <T> Stream<T> queryStream​(String sql,
                                         StreamingResultSetHandler<T> handler,
                                         Object... args)
                                  throws SQLException
        Executes a Query and returns a Stream in which each element represents a row in the result. (This method cannot be named "query" because it would hide the corresponding methods in the superclass.)
        Parameters:
        sql - The SQL query to execute
        handler - The ResultSetHandler that converts the ResultSet to a Stream
        args - The arguments to pass to the query as prepared statement parameters
        Throws:
        SQLException
      • queryStream

        public <T> Stream<T> queryStream​(Connection connection,
                                         String sql,
                                         StreamingResultSetHandler<T> handler,
                                         Object... args)
                                  throws SQLException
        Executes a Query and returns a Stream in which each element represents a row in the result. (This method cannot be named "query" because it would hide the corresponding methods in the superclass.)
        Parameters:
        connection - The database Connection to use
        sql - The SQL query to execute
        handler - The ResultSetHandler that converts the ResultSet to a Stream
        args - The arguments to pass to the query as prepared statement parameters
        Throws:
        SQLException