Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Which databases are the most used with Java Date: Mon, 14 Aug 2017 03:04:00 +0200 Organization: Decebal Computing Lines: 35 Message-ID: <877ey7q7sv.fsf@munus.decebal.nl> References: <87y3qovwjb.fsf@munus.decebal.nl> <87tw1bx2c9.fsf@munus.decebal.nl> <87a833wzcx.fsf@munus.decebal.nl> <87pobz9yv5.fsf@munus.decebal.nl> <871sofrwsk.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="b5e51ead2eb93bf4772adfe6a7284a95"; logging-data="25212"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3tI4w9UQQNHbVGD8Jgm4QgfGUAxKOtpY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:DMiVi+F1+Yob+3snoS1SGoj5RuM= sha1:GQ+CdX3sKnBpNS7Q8iJe1I9Lffo= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.java.programmer:37216 Arne Vajhøj writes: > On 8/13/2017 5:18 PM, Cecil Westerhof wrote: >> Arne Vajhøj writes: >>> There are also the possibility in some databases to execute multiple >>> SELECT in a single execute/executeQuery and then you will get more than >>> one ResultSet back. >>> >>> This is used like: >>> >>> Statement stmt = con.createStatement(); >>> ResultSet rs1 = stmt.executeQuery("..."); >>> ... >>> rs1.close(); >>> stmt.getMoreResults(); >>> ResultSet rs2 = stmt.getResultSet(); >>> ... >>> rs2.close(); >>> stmt.close(); >> >> Since Java7 we (or at least I) do not program that way anymore. You >> use try with resources. You only want the ResultSet, but to prevent a >> resource leak, you need to also create the Statement. That makes my >> hair stand up on the back of my neck. > > You have 3 levels of resources: Connection, Statement, ResultSet. > > You need 3 levels of try. Lets agree to disagree. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof