use of com.cadenzauk.core.sql.ResultSetSpliterator in project siesta by cadenzauk.
the class JdbcSqlExecutor method stream.
<T> Stream<T> stream(Connection connection, String sql, Object[] args, RowMapper<T> rowMapper, CompositeAutoCloseable closeable) {
try {
PreparedStatement preparedStatement = prepare(connection, sql, args, closeable);
preparedStatement.setFetchSize(fetchSize);
ResultSet resultSet = closeable.add(preparedStatement.executeQuery());
return StreamSupport.stream(new ResultSetSpliterator<>(resultSet, rowMapper, closeable::close), false).onClose(closeable::close);
} catch (RuntimeException e) {
closeable.close();
throw e;
} catch (SQLException e) {
closeable.close();
throw new RuntimeSqlException(e);
} catch (Exception e) {
closeable.close();
throw new RuntimeException(e);
}
}
Aggregations