{"id":13,"date":"2026-07-23T16:25:15","date_gmt":"2026-07-23T08:25:15","guid":{"rendered":"http:\/\/www.dxkua.cn\/?p=13"},"modified":"2026-07-23T16:25:16","modified_gmt":"2026-07-23T08:25:16","slug":"13","status":"publish","type":"post","link":"https:\/\/www.dxkua.cn\/index.php\/2026\/07\/23\/13\/","title":{"rendered":""},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>public class UserDaoImpl implements UserDao {\n    @Override\n    public int insert(User user)\/\/ ? throws Exception\n     {\n        String sql = \"insert into user(id,userNo,userName,pwd) values(?,?,?,?)\";\n        Object&#91;] param = new Object&#91;]{user.getId(),user.getUserNo(),user.getUserName(),user.getPwd()};\n        QueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n\n        int result = 0;\n\n\n        try {\n            result=queryRunner.update(sql,param);\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        }\n\n        return result;\n    }\n\n    @Override\n    public int delete(int id) {\n        String sql = \"delete from user where id=?\";\nObject&#91;] param = new Object&#91;]{id};\nQueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n\n        int result = 0;\n        try {\n          result = queryRunner.update(sql,param);\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n        return result;\n    }\n\n    @Override\n    public int update(User user) {\n        String sql = \"update user set userNo=?,userName=? where id=?\";\nObject&#91;] param = new Object&#91;]{user.getUserNo(),user.getUserName(),user.getId()};\nQueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n        int result = 0;\n        try {\n       result = queryRunner.update(sql,param);\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n        return result;\n\n    }\n\n    @Override\n    public List&lt;User> selectAll() {\n        String sql = \"select * from user\";\n\nQueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n        List&lt;User> list = new ArrayList&lt;User>();\n        try {\n         list=queryRunner.query(sql,new BeanListHandler&lt;User>(User.class));\n            } catch (SQLException ex) {\n            throw new RuntimeException(ex);\n        }\n\n        return list;\n\n    }\n\n    @Override\n    public List&lt;User> selectByName(String name) {\n        String sql = \"select * from user where userName=?\";\n        Object&#91;] param = new Object&#91;]{name};\n        QueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n        List&lt;User> list = new ArrayList&lt;User>();\n\n        ResultSet result;\n        try {\n          list=queryRunner.query(sql,param,new BeanListHandler&lt;User>(User.class));\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n\n        return list;\n    }\n\n    @Override\n    public User selectById(int id) {\n\n\n        String sql = \"select * from user where id=?\";\n        Object&#91;] param = new Object&#91;]{id};\n        User user = new User();\nQueryRunner queryRunner = new QueryRunner(JdbcUtil.getDataSource());\n\n        try {\n        user = queryRunner.query(sql,param,new BeanHandler&lt;User>(User.class));\n        } catch (SQLException e) {\n            throw new RuntimeException(e);\n        } catch (Exception e) {\n            throw new RuntimeException(e);\n        }\n\n        return user;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":1,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/posts\/13\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dxkua.cn\/index.php\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}