Path: csiph.com!aioe.org!.POSTED.O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: it's Closeable, but I don't want to close() it yet. Date: Mon, 4 Mar 2019 13:59:37 -0500 Organization: Aioe.org NNTP Server Lines: 24 Message-ID: References: <709a1f3b-fc99-4bd0-a8b8-866092bb7ae9@googlegroups.com> <8e1597a2-5c18-4fd1-83a4-7667e4d11e77@googlegroups.com> <23a8128b-5c54-45ba-bfd0-2f7dda078517@googlegroups.com> NNTP-Posting-Host: O5hsyUvK01te0L/SZurVSQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:38786 On 2/28/2019 11:24 AM, bursejan@gmail.com wrote: > Actually you use try (resource), which does automatically > always a close. Its internally implemented with try finally > and does exceptiong piggy packing. > > But JDBC says, if you close a statement, I guess result > sets are also closed. And if you close a connection, statements > are also closed. So what is this fuzz about? The JDBC standard defines that Connection close should call Statement close and that Statement close should call ResultSet close. I believe the normal practice in Java is to close ResultSet and Statement explicit (including try with resource). Two possible explanations: * not everyone reads the JDBC spec so closing explicit is nice to readers * a given driver implementation may have forgotten that part Arne