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: Tue, 15 Aug 2017 16:33:25 +0200 Organization: Decebal Computing Lines: 63 Message-ID: <87378soq8a.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> <87h8x9pfi8.fsf@munus.decebal.nl> <877ey5ngtu.fsf@munus.decebal.nl> <6b0c0b97-8517-4f08-b512-fc3f3054fbb6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="72fb8bea0235c6b94245dccb186de60d"; logging-data="6544"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19B2hKsmQowWxzRnWzIkXHp4ZMGqUALNz8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:dBPW3jReQcbXrqhFOdakXEhh/50= sha1:YZ/SpSGRQJ/E62sUhIT0+1NxVYY= Xref: csiph.com comp.lang.java.programmer:37238 Eric Douglas writes: > On Tuesday, August 15, 2017 at 8:44:21 AM UTC-4, Cecil Westerhof wrote: >> > To the contrary, more than once you have been advised to reuse one >> > statement to create multiple result sets in sequence. >> >> Yes I am sure about that. But probably another thread. >> >> >> > You seem to insist on Statement being an evil ploy designed by the JDBC >> > inventors to force you to write unnecessary boiler plate code when all >> > you want is just a ResultSet. Whatever follows from this line of >> > reasoning is not likely to be correct or useful, I'm afraid. >> >> I do not see Statement as an evil ploy. But I think that with try with >> resources it is something you do not need explicit anymore. >> If you do not like what I am making, nobody forces you to use it. >> >> >> And even if it is useless, I am learning while making it. >> > > You are not learning if you completely ignore what everyone is > telling you. Are you trolling me? If you had paid a little attention you would have seen that I implemented suggestions. How is that completely ignoring what everyone is telling me? > 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. 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? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof