Path: csiph.com!news.redatomik.org!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Testing the functionality of sub classes Date: Sun, 20 Aug 2017 11:14:26 -0400 Organization: Aioe.org NNTP Server Lines: 40 Message-ID: References: <87fucnh2wu.fsf@munus.decebal.nl> <87y3qffim5.fsf@munus.decebal.nl> <87pobrf855.fsf@munus.decebal.nl> <87ziaue74o.fsf@munus.decebal.nl> <87valie4xz.fsf@munus.decebal.nl> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:37318 On 8/20/2017 10:33 AM, Andreas Leitgeb wrote: > Arne Vajhøj wrote: >> On 8/20/2017 9:36 AM, Cecil Westerhof wrote: >>> Cecil Westerhof writes: >>>> 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. >>> >>> With a H2 database I get: >>> stat0 >>> rs0: null >>> rs1: org.h2.result.LocalResult@1bc6a36e columns: 1 rows: 1 pos: -1 >> >> That is what happens when you try and do unsupported things: you get >> undefined/implementation specific behavior. Bad! > > In this particular case the "undefined/implementation specific behavior" > is ResultSet-implementation's toString(). That's why I suggested to use > System.identityHashCode(). It is more than that. SQLite reuse result set object - H2 does not. Arne