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: Sun, 13 Aug 2017 12:12:14 +0200 Organization: Decebal Computing Lines: 38 Message-ID: <87a833wzcx.fsf@munus.decebal.nl> References: <87y3qovwjb.fsf@munus.decebal.nl> <87tw1bx2c9.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="1615173a1409002a85fbdd25ac4b9ead"; logging-data="27802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ncN8Xn0XGy3piy1pY4tDqJKWtrNv4PP4=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Homepage: http://www.decebal.nl/ Cancel-Lock: sha1:csZhDHkZX5DnMvAN6DQD7nvDUNk= sha1:PFGZxqh49ehyesUvLJfswyUWko8= Xref: csiph.com comp.lang.java.programmer:37170 Andreas Leitgeb writes: > Cecil Westerhof wrote: >> It started with that I really do not like: >> try (Statement stmt = conn.createStatement(); >> ResultSet rsOldest = sqlite3Conn.executeQuery(OLDEST_USED)) { >> I now can do: >> try (SQLResultSet rsOldest = sqlite3Conn.executeQuery(OLDEST_USED)) { > > I want one Lego(tm) brick, so I'm going to write a method that takes an > acre of wood land, cuts down the trees, builds a factory that produces one > brick then knocks down the factory and plants trees - all in one call! > How convenient! ;-) I do nothing more as usual, I only hide the things that are not important. It is a bit like generics: first you needed to define the type on both sides of the statement, now only at one. With try with resources you never (I think) need a Statement. The Statement is needed for the ResultSet. So I only want to create the ResultSet and let it handle the implicit Statement. > And if I ever need ten bricks, I'll just call it ten times... If you need 10 ResultSets, you also need 10 Statements. That was the reason I started with this exercise. And if I need 10 ResultSets, I just saved typing in the code for getting 10 Statements. I am happy. :-D Also: with the not really needed Statements you increase the risk of bugs. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof