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: Testing the functionality of sub classes Date: Sun, 20 Aug 2017 18:17:02 +0200 Organization: Decebal Computing Lines: 42 Message-ID: <87d17qdxj5.fsf@munus.decebal.nl> References: <87fucnh2wu.fsf@munus.decebal.nl> <87y3qffim5.fsf@munus.decebal.nl> <87pobrf855.fsf@munus.decebal.nl> <87ziaue74o.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="a3233d099e71e24d901953f13bac9801"; logging-data="14609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KqPzRl29Zk+VLMd0lx2OCIcudCIdg3w4=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:pn2mbzhglf2RGLMHwzJnuqzIWfg= sha1:h8W7UXbowTp5MtDIiy+zBt14kKc= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.java.programmer:37323 Arne Vajhøj writes: > On 8/20/2017 8:49 AM, Cecil Westerhof wrote: >> Just to satisfy my curiosity I executed (I do not like the formatting, >> but that is what Eclipse does): >> try ( >> Statement stmt = conn.createStatement(); >> ResultSet rsOne = stmt.executeQuery("SELECT 12 AS twelve"); >> ResultSet rsTwo = stmt.executeQuery("SELECT 'Hello World!' AS message") >> ) { >> System.out.println(stmt); >> System.out.println(rsOne); >> System.out.println(rsTwo); >> } >> >> And this gives: >> org.sqlite.jdbc4.JDBC4Statement@685f4c2e >> org.sqlite.jdbc4.JDBC4ResultSet@7daf6ecc >> org.sqlite.jdbc4.JDBC4ResultSet@7daf6ecc >> >> So yes, it is like you said: the ResultSet is reused. Is also more >> logical. I jumped to a conclusion. > > As soon as the second executeQuery is running then whatever rsOne > is pointing to is supposed to be toast. > > So SQLite JDBC driver apparently decide to reuse the object for > the second executeQuery. > > Maybe unexpected, but I believe it is OK per spec. In the description of Statement (copied with spelling mistakes): All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists. Well, maybe you could say it is OK to reuse the old one, but it certainly does surprise me. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof