Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Which databases are the most used with Java Date: Tue, 15 Aug 2017 11:12:33 -0400 Organization: Aioe.org NNTP Server Lines: 42 Message-ID: References: <87y3qovwjb.fsf@munus.decebal.nl> <87tw1bx2c9.fsf@munus.decebal.nl> <87a833wzcx.fsf@munus.decebal.nl> <87pobz9yv5.fsf@munus.decebal.nl> <87h8x9pfi8.fsf@munus.decebal.nl> <877ey5ngtu.fsf@munus.decebal.nl> <6b0c0b97-8517-4f08-b512-fc3f3054fbb6@googlegroups.com> <87378soq8a.fsf@munus.decebal.nl> NNTP-Posting-Host: LO3gx2vFpREKIznvPHDlcg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:37243 On 8/15/2017 10:33 AM, Cecil Westerhof wrote: > Eric Douglas writes: >> Again, read the javadocs. You are not intended to create one Statement for every single ResultSet. >> http://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html#createStatement-int-int- >> "Creates a Statement object that will generate ResultSet objects" >> objects, plural. > > And it ends with: Since: 1.2. I am using a version of Java that is a > little newer. That just mean that method has been available since 1.2 - not that it should not be used with newer versions. > By the way at https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html > there is the following code: > try (Statement stmt = con.createStatement()) { > ResultSet rs = stmt.executeQuery(query); > > while (rs.next()) { > String coffeeName = rs.getString("COF_NAME"); > int supplierID = rs.getInt("SUP_ID"); > float price = rs.getFloat("PRICE"); > int sales = rs.getInt("SALES"); > int total = rs.getInt("TOTAL"); > > System.out.println(coffeeName + ", " + supplierID + ", " + > price + ", " + sales + ", " + total); > } > } catch (SQLException e) { > JDBCTutorialUtilities.printSQLException(e); > } > > Are you going to tell Oracle that they are doing it wrong? They use 1 Statement to 1 ResultSet - it does not show either 1 Statement N ResultSet or N Statement N ResultSet. (BTW I think Oracle did it wrong rs is not closed) Arne