
{"id":2389,"date":"2020-10-18T15:27:48","date_gmt":"2020-10-18T07:27:48","guid":{"rendered":"http:\/\/admin.evshou.com\/?p=2389"},"modified":"2020-10-19T17:12:26","modified_gmt":"2020-10-19T09:12:26","slug":"2020javaweb%e6%95%99%e7%a8%8b%e4%b9%8bdao%e5%ae%9e%e7%8e%b0%e6%9f%a5%e8%af%a2%e9%80%9a%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=2389","title":{"rendered":"2020Javaweb\u6559\u7a0b\u4e4bdao\u5b9e\u73b0\u67e5\u8be2\u901a\u7528\u65b9\u6cd5"},"content":{"rendered":"<h3>2020Javaweb\u6559\u7a0b\u4e4bdao\u5b9e\u73b0\u67e5\u8be2\u901a\u7528\u65b9\u6cd5<\/h3>\n<p>DButils\uff1a<\/p>\n<pre>public static &lt;T&gt; List&lt;T&gt; select(String sql, RowMapper&lt;T&gt; rm, Object... o){\r\n    List&lt;T&gt; list=new ArrayList&lt;T&gt;();<\/pre>\n<pre><!--more-->\r\n\r\n\r\n    try{\r\n        connection=getConnection();\r\n        ps=connection.prepareStatement(sql);\r\n        for(int i=0;i&lt;o.length;i++){\r\n            ps.setObject(i+1,o[i]);\r\n        }\r\n        rs=ps.executeQuery();\r\n       while (rs.next()){\r\n           list.add(rm.select(rs));\r\n       }\r\n       return list;\r\n    }catch (Exception e){}\r\n    return null;\r\n}<\/pre>\n<p>\u6620\u5c04\u7c7b\u63a5\u53e3\uff1aRowMapper<\/p>\n<pre>public interface RowMapper&lt;T&gt; {\r\n    T select(ResultSet rs);\r\n}<\/pre>\n<p>\u63a5\u53e3\u5b9e\u73b0\u7c7b\uff1a<\/p>\n<pre>public class StudentRowMapper implements RowMapper&lt;Student&gt; {\r\n    @Override\r\n    public Student select(ResultSet rs) {\r\n        Student s=new Student();\r\n        try{\r\n            s.setSid(rs.getInt(1));\r\n            s.setSname(rs.getString(\"sname\"));\r\n            s.setSage(rs.getInt(\"sage\"));\r\n            s.setSsex(rs.getString(\"ssex\"));\r\n            s.setBirthday(rs.getDate(\"birthday\"));\r\n            s.setScore(rs.getDouble(\"score\"));\r\n        }catch (Exception e){}\r\n        return s;\r\n    }\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>2020Javaweb\u6559\u7a0b\u4e4bdao\u5b9e\u73b0\u67e5\u8be2\u901a\u7528\u65b9\u6cd5 DButils\uff1a public static &lt;T&#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-2389","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2389"}],"version-history":[{"count":2,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2389\/revisions"}],"predecessor-version":[{"id":2395,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/2389\/revisions\/2395"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}