Package org.httprpc.sql
Class ResultSetAdapter
- java.lang.Object
-
- org.httprpc.sql.ResultSetAdapter
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>>
public class ResultSetAdapter extends java.lang.Object implements java.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>>, java.lang.AutoCloseable
Class that presents the contents of a result set as an iterable sequence of maps. Map instances are mutable, and column order is preserved.
-
-
Constructor Summary
Constructors Constructor Description ResultSetAdapter(java.sql.ResultSet resultSet)
Constructs a new result set adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
int
getFetchSize()
Returns the result set's fetch size.java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>>
iterator()
java.util.Map<java.lang.String,java.lang.Object>
next()
Returns the next result.void
setFetchSize(int fetchSize)
Sets the result set's fetch size.java.util.stream.Stream<java.util.Map<java.lang.String,java.lang.Object>>
stream()
Returns a stream over the results.
-
-
-
Method Detail
-
getFetchSize
public int getFetchSize() throws java.sql.SQLException
Returns the result set's fetch size.- Returns:
- The result set's fetch size.
- Throws:
java.sql.SQLException
- If an error occurs while retrieving the fetch size.
-
setFetchSize
public void setFetchSize(int fetchSize) throws java.sql.SQLException
Sets the result set's fetch size.- Parameters:
fetchSize
- The result set's fetch size.- Throws:
java.sql.SQLException
- If an error occurs while setting the fetch size.
-
next
public java.util.Map<java.lang.String,java.lang.Object> next()
Returns the next result.- Returns:
- The next result, or
null
if there are no more results.
-
iterator
public java.util.Iterator<java.util.Map<java.lang.String,java.lang.Object>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.util.Map<java.lang.String,java.lang.Object>>
-
close
public void close() throws java.sql.SQLException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.sql.SQLException
-
stream
public java.util.stream.Stream<java.util.Map<java.lang.String,java.lang.Object>> stream()
Returns a stream over the results. Closing the returned stream does not close the underlying result set.- Returns:
- A stream over the results.
-
-