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:06:33 -0400 Organization: Aioe.org NNTP Server Lines: 39 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> 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:37241 On 8/15/2017 1:27 AM, Cecil Westerhof wrote: > Eric Douglas writes: >> On Sunday, August 13, 2017 at 1:14:17 PM UTC-4, Cecil Westerhof wrote: >>> What is wrong about that? A Statement can only have one ResultSet. So >>> if you have 10 (independent) ResultSets you have 10 Statements. >>> >> >> Wrong, read the Javadoc. >> http://docs.oracle.com/javase/8/docs/api/java/sql/CallableStatement.html >> "can return one ResultSet object or multiple ResultSet objects" > > That is certainly interesting, but that extends PreparedStatement, not > Statement. CallableStatement extends PreparedStatement that extends Statement. I did mention in a previous note that some databases allow multiple SELECT in a single executeQuery. Stored procedures execute via CallableStatement execute behaves the same way. > Earlier I was told that the way to do things was something like: > try (Statement stmtOldest = conn.createStatement(); > ResultSet rsOldest = stmtOldest.executeQuery(OLDEST_USED) > Statement stmtNewest = conn.createStatement(); > ResultSet rsNewest = stmtNewest.executeQuery(OLDEST_USED) > Statement stmtCount = conn.createStatement(); > ResultSet rsCount = stmtCount.executeQuery(OLDEST_USED)) { As long as you complete using a ResultSet before opening the next then you can reuse the same Statement. But if yo do not do that then using same Statement (and same Connection - unlike it supports something like MARS) will get you in problems. Arne