{"id":1669,"date":"2013-01-06T04:06:09","date_gmt":"2013-01-06T02:06:09","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=1669"},"modified":"2013-01-06T04:06:09","modified_gmt":"2013-01-06T02:06:09","slug":"erste-libs-springen-auf-java-8-auf","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2013\/01\/erste-libs-springen-auf-java-8-auf\/","title":{"rendered":"Erste Libs springen auf Java 8 auf"},"content":{"rendered":"<p>So etwa <a title=\"http:\/\/www.jdbi.org\/\" href=\"http:\/\/www.jdbi.org\/\">http:\/\/www.jdbi.org\/<\/a>.<\/p>\n<blockquote>\n<p><a href=\"http:\/\/jdbi.org\/\">JDBI<\/a> is a SQL convenience library for Java.<\/p>\n<\/blockquote>\n<p>Beispiel von der Seite in herk\u00f6mmlicher Notation:<\/p>\n<pre><code>DataSource ds = JdbcConnectionPool.create(&quot;jdbc:h2:mem:test&quot;,\n                                          &quot;username&quot;,\n                                          &quot;password&quot;);\nDBI dbi = new DBI(ds);\nHandle h = dbi.open();\nh.execute(&quot;create table something (id int primary key, name varchar(100))&quot;);\n\nh.execute(&quot;insert into something (id, name) values (?, ?)&quot;, 1, &quot;Brian&quot;);\n\nString name = h.createQuery(&quot;select name from something where id = :id&quot;)\n                    .bind(&quot;id&quot;, 1)\n                    .map(StringMapper.FIRST)\n                    .first();\n                    \nassertThat(name, equalTo(&quot;Brian&quot;));\n\nh.close();<\/code><\/pre>\n<p><a title=\"http:\/\/skife.org\/jdbi\/2012\/12\/10\/some-jdbi3.html\" href=\"http:\/\/skife.org\/jdbi\/2012\/12\/10\/some-jdbi3.html\">http:\/\/skife.org\/jdbi\/2012\/12\/10\/some-jdbi3.html<\/a> schreibt nun, dass JDBI 3 Lambda-Ausdr\u00fccke nutzen wird und gibt folgendes Beispiel an:<\/p>\n<pre><code>Set&lt;Something&gt; things = jdbi.withHandle(h -&gt; {\n    h.execute(&quot;insert into something (id, name) values (?, ?)&quot;, 1, &quot;Brian&quot;);\n    h.execute(&quot;insert into something (id, name) values (?, ?)&quot;, 2, &quot;Steven&quot;);\n\n    return h.query(&quot;select id, name from something&quot;)\n            .map(rs -&gt; new Something(rs.getInt(1), rs.getString(2)))\n            .into(new HashSet&lt;Something&gt;());\n});\n\nassertThat(things).isEqualTo(ImmutableSet.of(new Something(1, &quot;Brian&quot;),\n                                             new Something(2, &quot;Steven&quot;)));<\/code><\/pre>\n<p>Das geht sicherlich noch etwas k\u00fcrzer, warten wir\u2019s ab.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So etwa http:\/\/www.jdbi.org\/. JDBI is a SQL convenience library for Java. Beispiel von der Seite in herk\u00f6mmlicher Notation: DataSource ds = JdbcConnectionPool.create(&quot;jdbc:h2:mem:test&quot;, &quot;username&quot;, &quot;password&quot;); DBI dbi = new DBI(ds); Handle h = dbi.open(); h.execute(&quot;create table something (id int primary key, name varchar(100))&quot;); h.execute(&quot;insert into something (id, name) values (?, ?)&quot;, 1, &quot;Brian&quot;); String name = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[66],"tags":[],"class_list":["post-1669","post","type-post","status-publish","format-standard","hentry","category-java-8"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1669","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/comments?post=1669"}],"version-history":[{"count":0,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/1669\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=1669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=1669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=1669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}