Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: Testing the functionality of sub classes Date: Sun, 20 Aug 2017 14:33:13 -0000 (UTC) Organization: A noiseless patient Spider Lines: 35 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> Reply-To: avl@logic.at Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 20 Aug 2017 14:33:13 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="cd31f327af7298cb41a335016b661fc8"; logging-data="19323"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GJ0IK60mh89DlMdGiu1az" User-Agent: slrn/1.0.2 (Linux) Cancel-Lock: sha1:I98yzNaGz2fuUBzUEIHa1lw1wFY= Xref: csiph.com comp.lang.java.programmer:37316 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().