JDBC improvements and convenience method suggestions
Philippe Marschall
pm at netcetera.ch
Wed Jul 18 07:43:30 UTC 2018
On 12.07.18 20:25, Mark Rotteveel wrote:
> On 12-7-2018 17:43, Lukas Eder wrote:
>> But Iterable is definitely useful. Imagine, with the previous
>> improvements
>> to do this:
>>
>> try (ResultSet rs = connection.executeQuery("SELECT * FROM t")) {
>> for (Object[] row : rs) {
>> System.out.println(row[0] + ":" + row[1]);
>> }
>> }
>>
>> Makes me wish for a for-with-resources as well that iterates over
>> (Iterable<T> & AutoCloseable) and closes the object after (un)successful
>> iteration :-)
>
> That might indicate that instead of a `Iterator`, we should add
> `stream()`, as a `Stream` does implement `Closeable` and would achieve
> this as well.
IMO supporting Stream encourages doing in Java (eg. #filter(), #max(),
...) what should be done in SQL.
Cheers
Philippe
More information about the jdbc-spec-discuss
mailing list