Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Which databases are the most used with Java Date: Sun, 13 Aug 2017 20:26:15 +0200 Lines: 55 Message-ID: References: <87y3qovwjb.fsf@munus.decebal.nl> <87tw1bx2c9.fsf@munus.decebal.nl> <87a833wzcx.fsf@munus.decebal.nl> <87pobz9yv5.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net IxptgcfSqoav8tTe7Cqu8w83G8bav4JzZ0Zxjiyd4BtWVGeT0= Cancel-Lock: sha1:U7BCGfGPIe0GK5Hv42uE4/3XCJs= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: <87pobz9yv5.fsf@munus.decebal.nl> Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:37188 On 13.08.2017 19:11, Cecil Westerhof wrote: > Robert Klemme writes: > >> On 13.08.2017 12:12, Cecil Westerhof wrote: >>> Andreas Leitgeb writes: >> >>>> And if I ever need ten bricks, I'll just call it ten times... >>> >>> If you need 10 ResultSets, you also need 10 Statements. >> >> This is wrong. > > What is wrong about that? A Statement can only have one ResultSet. So > if you have 10 (independent) ResultSets you have 10 Statements. There are several ways to get more than one ResultSet from a Statement. The simplest is to invoke executeQuery(String) multiple times. There are more fancy approaches like the batch processing. https://docs.oracle.com/javase/8/docs/api/java/sql/Statement.html >>> Also: with the not really needed Statements you increase the risk of >>> bugs. >> >> Not sure what you mean by that. > > It would not be the first time that someone used similar names for > different variables and use the wrong one at a certain point. When you > double your variables, you increase the risk of making a mistake. So the argument is, because there is a variable of type Statement and a variable of type ResultSet there are twice as many as with your wrapper where there is just one variable of type SQLResultSet. And the more variables the bigger the risk for mistakes. Do I understand your point correctly? In this particular case the chance of mistakenly using the wrong of two variables is pretty small I'd say since the number of methods with identical signatures or even with identical names between Statement and ResultSet will be fairly small. I still do not see the value in this approach. The cost of creating and maintaining that wrapper library and not working with original types (for some RDBMS to use some special functionality you need to cast the interface types to concrete types of that DB) seems to outweigh the benefit. That is, unless I have overlooked something. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/