Class StreamingQueryRunner
- java.lang.Object
-
- org.apache.commons.dbutils.AbstractQueryRunner
-
- org.apache.commons.dbutils.QueryRunner
-
- dev.aherscu.qa.jgiven.jdbc.utils.dbutils.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.
-
-
Constructor Summary
Constructors Constructor Description StreamingQueryRunner(DataSource dataSource)
-
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 executehandler
- The ResultSetHandler that converts the ResultSet to a Streamargs
- The arguments to pass to the query as prepared statement parameters- Throws:
SQLException
-
queryStream
public Stream<Object[]> queryStream(String sql, Object... args) throws SQLException
- 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 usesql
- The SQL query to executehandler
- The ResultSetHandler that converts the ResultSet to a Streamargs
- The arguments to pass to the query as prepared statement parameters- Throws:
SQLException
-
-