Path: csiph.com!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.xdsl-78-35-246-212.netcologne.de!not-for-mail From: Patrick Roemer Newsgroups: comp.lang.java.programmer Subject: Re: Is this the way to work with try with resources Date: Wed, 9 Aug 2017 15:39:25 +0200 Organization: news.netcologne.de Distribution: world Message-ID: References: <87poc6wb9n.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Wed, 9 Aug 2017 13:39:25 +0000 (UTC) Injection-Info: newsreader4.netcologne.de; posting-host="xdsl-78-35-246-212.netcologne.de:78.35.246.212"; logging-data="14935"; mail-complaints-to="abuse@netcologne.de" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.24) Gecko/20100411 Thunderbird/2.0.0.24 Mnenhy/0.7.6.0 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:37111 Responding to Stefan Ram: > private static void > runQueryProc > ( final java.sql.Statement statement, > final java.lang.String query, > final java.util.function.Consumer< java.sql.ResultSet >consumer ) > throws java.sql.SQLException > { try( final java.sql.ResultSet set = statement.executeQuery( query )) > { consumer.accept( set ); }} [...] Yep, but you'll need custom interfaces instead of Consumer/Function to cater for the SQLException. Best regards, Patrick