{"id":118087,"date":"2026-10-26T07:16:22","date_gmt":"2026-10-25T23:16:22","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/118087.html"},"modified":"2026-10-26T07:16:22","modified_gmt":"2026-10-25T23:16:22","slug":"%e3%80%90%e4%bb%93%e9%a2%89%e8%af%ad%e8%a8%80%e5%85%a5%e9%97%a8-%c2%b7-%e7%ac%ac%e4%ba%8c%e7%af%87-%e7%ac%ac-15-%e8%af%be%e3%80%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/118087.html","title":{"rendered":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011"},"content":{"rendered":"<h2>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011\u7efc\u5408\u5b9e\u6218&#xff1a;\u628a Todo \u6e05\u5355\u642c\u4e0a\u6570\u636e\u5e93<\/h2>\n<p>\u5bfc\u822a&#xff1a;\u4e0a\u4e00\u8bfe \u7b2c 14 \u8bfe \u624b\u5199 DAO \u6570\u636e\u8bbf\u95ee\u5c42 \u2192 \u672c\u8bfe \u2192 \u4e0b\u4e00\u8bfe \u7b2c 16 \u8bfe \u53cd\u5c04<\/p>\n<p>\u672c\u8bfe\u5185\u5bb9\u91cf&#xff1a;\u6b63\u6587\u7ea6 380 \u884c&#xff0c;\u5168\u7bc7\u7ea6 580 \u884c&#xff08;\u542b\u5bfc\u822a \/ FAQ \/ \u9884\u544a \/ \u4e8c\u7ef4\u7801\u9aa8\u67b6&#xff09;\u3002\u5355\u8bfe\u53ea\u805a\u7126 1 \u4e2a\u77e5\u8bc6\u70b9&#xff1a;\u628a\u524d 8 \u8bfe\u8bb2\u8fc7\u7684 SQL \u80fd\u529b&#xff08;\u5efa\u8868\u3001CRUD\u3001\u9884\u7f16\u8bd1\u3001\u4e8b\u52a1\u3001DAO&#xff09;\u4e32\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u5c0f\u9879\u76ee&#xff0c;\u4e0d\u5f15\u5165\u65b0\u8bed\u6cd5\u3001\u65b0\u6982\u5ff5\u3001\u65b0\u4f9d\u8d56\u3002\u672c\u8bfe\u672c\u8eab\u5c31\u662f\u7efc\u5408\u5b9e\u6218\u9879\u76ee&#xff0c;\u7167\u7740\u8dd1\u901a\u3001\u8f93\u51fa\u548c\u6559\u7a0b\u5bf9\u4e0a\u3001\u81ea\u5df1\u6539\u6539\u518d\u8dd1\u4e00\u904d\u5c31\u662f\u6700\u597d\u7684\u7ec3\u4e60\u2014\u2014\u4e0d\u518d\u989d\u5916\u8bbe\u8bfe\u540e\u7ec3\u4e60\u9898\u3002<\/p>\n<p>\u4ee3\u7801\u4e0b\u8f7d&#xff1a;\u672c\u8bfe\u5b8c\u6574\u9879\u76ee\u6253\u5305\u5728 lesson15_todo.zip<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4ece\u6587\u4ef6\u5230\u6570\u636e\u5e93&#xff1a;\u4e3a\u4ec0\u4e48\u53c8\u6765\u4e00\u6b21 Todo&#xff1f;<\/h3>\n<p>\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;Todo \u6e05\u5355\u6709\u5565\u597d\u5199\u7684&#xff1f;\u7b2c\u4e00\u7bc7\u7b2c 29 \u8bfe\u4e0d\u5c31\u662f\u4e00\u4e2a\u6587\u4ef6\u7248 Todo \u6e05\u5355\u5417&#xff1f;<\/p>\n<p>\u90a3\u6211\u4eec\u56de\u5934\u770b\u770b\u7b2c 29 \u8bfe\u7684\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u7528 std.fs \u8bfb\u5199\u4e00\u4e2a txt \u6587\u4ef6&#xff0c;\u6bcf\u6761 Todo \u4e00\u884c<\/li>\n<li>\u4e1a\u52a1\u903b\u8f91\u5168\u5806\u5728 main \u91cc&#xff0c;\u6ca1\u6709\u5206\u5c42<\/li>\n<li>Todo \u672c\u8eab\u662f struct Todo(title: String, done: Bool) \u8fd9\u6837\u7684\u7eaf\u6570\u636e<\/li>\n<li>\u8bfb\u5199\u6587\u4ef6\u4e00\u5361&#xff0c;\u6574\u4e2a\u7a0b\u5e8f\u5c31\u5361<\/li>\n<\/ul>\n<p>\u73b0\u5728\u6362\u4e00\u4e2a\u7248\u672c&#xff1a;\u5b58\u5230\u6570\u636e\u5e93\u91cc\u3002\u8fd9\u6b21\u6211\u4eec\u7528\u6570\u636e\u5e93\u505a\u5b58\u50a8\u5c42&#xff0c;\u5176\u4ed6\u4e00\u5207\u2014\u2014\u9879\u76ee\u9aa8\u67b6\u3001\u6570\u636e\u6a21\u578b\u3001\u4e1a\u52a1\u903b\u8f91\u2014\u2014\u5168\u548c\u7b2c 29 \u8bfe\u4e00\u6a21\u4e00\u6837\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u672c\u8bfe\u8981\u8bb2\u7684\u6838\u5fc3\u601d\u60f3&#xff1a;<\/p>\n<p>\u5b58\u50a8\u5c42\u53ef\u4ee5\u66ff\u6362&#xff0c;\u4e1a\u52a1\u903b\u8f91\u4e0d\u5fc5\u8ddf\u7740\u6362\u3002<\/p>\n<p>\u6587\u4ef6\u7248\u3001\u6570\u636e\u5e93\u7248\u3001\u672a\u6765 Redis \u7248\u2014\u2014\u5bf9&#034;\u7528\u6237\u60f3\u52a0\u4e00\u6761 Todo&#034;\u8fd9\u4ef6\u4e8b\u6765\u8bf4&#xff0c;\u4e1a\u52a1\u903b\u8f91\u6c38\u8fdc\u662f&#034;\u628a\u8fd9\u884c\u5b57\u5199\u8fdb\u53bb &#043; \u8bb0\u4e00\u4e2a\u5df2\u5b8c\u6210\u6807\u8bb0&#034;\u3002\u81f3\u4e8e\u5199\u5230\u54ea\u3001\u600e\u4e48\u5199&#xff0c;\u90a3\u662f\u5b58\u50a8\u5c42\u7684\u4e8b\u3002<\/p>\n<p>\u8fd9\u79cd\u5206\u5c42\u5728\u4e2d\u5927\u578b\u9879\u76ee\u91cc\u968f\u5904\u53ef\u89c1&#xff1a;\u7535\u5546\u7cfb\u7edf\u6362\u4e86\u4e2a\u65b0\u6570\u636e\u5e93\u3001\u6d88\u606f\u7cfb\u7edf\u6362\u4e86\u4e2a\u65b0\u4e2d\u95f4\u4ef6\u3001\u7f13\u5b58\u6362\u4e86\u4e2a\u65b0\u5382\u5546\u2014\u2014\u4e0a\u9762\u7684\u4e1a\u52a1\u4ee3\u7801\u4e00\u884c\u4e0d\u52a8\u3002\u672c\u8bfe\u901a\u8fc7\u4e00\u4e2a\u6781\u7b80\u7684 Todo \u9879\u76ee&#xff0c;\u8ba9\u4f60\u4eb2\u624b\u8d70\u4e00\u904d\u8fd9\u4e2a\u5206\u5c42\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u8868\u8bbe\u8ba1&#xff1a;\u5148\u5efa\u8868\u518d\u5f00\u5e72<\/h3>\n<p>\u9879\u76ee\u6d89\u53ca\u4e24\u4e2a\u5b9e\u4f53\u3001\u4e24\u5f20\u8868&#xff1a;\u7528\u6237&#xff08;user&#xff09;\u548c\u4ed6\u7684 Todo&#xff08;todo&#xff09;\u3002\u5173\u7cfb\u5f88\u7b80\u5355\u2014\u2014\u4e00\u4e2a\u7528\u6237\u53ef\u4ee5\u6709\u5f88\u591a Todo&#xff08;\u4e00\u5bf9\u591a&#xff09;\u3002<\/p>\n<p>\u5efa\u8868 SQL&#xff08;\u548c\u7b2c 08 \u8bfe DDL \u7ae0\u8282\u8bb2\u7684\u8bed\u6cd5\u4e00\u81f4&#xff09;&#xff1a;<\/p>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> <span class=\"token keyword\">user<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n    id   <span class=\"token keyword\">BIGINT<\/span> <span class=\"token keyword\">PRIMARY<\/span> <span class=\"token keyword\">KEY<\/span> <span class=\"token keyword\">AUTO_INCREMENT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    name <span class=\"token keyword\">VARCHAR<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span> <span class=\"token keyword\">UNIQUE<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> todo <span class=\"token punctuation\">(<\/span><br \/>\n    id      <span class=\"token keyword\">BIGINT<\/span> <span class=\"token keyword\">PRIMARY<\/span> <span class=\"token keyword\">KEY<\/span> <span class=\"token keyword\">AUTO_INCREMENT<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    user_id <span class=\"token keyword\">BIGINT<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    title   <span class=\"token keyword\">VARCHAR<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">256<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    done    <span class=\"token keyword\">TINYINT<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span> <span class=\"token keyword\">DEFAULT<\/span> <span class=\"token number\">0<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8bbe\u8ba1\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>user \u7684 name \u4e0a\u52a0\u4e86 UNIQUE \u7ea6\u675f\u2014\u2014\u4e0d\u5141\u8bb8\u4e24\u4e2a\u7528\u6237\u91cd\u540d<\/li>\n<li>todo.done \u7528 TINYINT(1) \u5b58 0\/1&#xff08;False\/True&#xff09;&#xff0c;\u548c\u6570\u636e\u5e93 BOOLEAN \u7684\u5e38\u89c1\u5199\u6cd5\u5bf9\u9f50<\/li>\n<li>\u6ca1\u6709\u52a0\u5916\u952e\u7ea6\u675f&#xff08;FOREIGN KEY (user_id) REFERENCES user(id)&#xff09;\u3002\u6559\u5b66\u7b80\u5316&#xff1a;\u6211\u4eec\u7528&#034;\u5e94\u7528\u5c42&#034;\u4fdd\u8bc1 user_id \u6709\u6548&#xff08;DAO \u91cc\u5148\u67e5 user \u662f\u5426\u5b58\u5728&#xff09;&#xff0c;\u4e0d\u641e\u6570\u636e\u5e93\u7ea7\u8054\u3002\u521d\u5b66\u8005\u9636\u6bb5&#xff0c;\u80fd\u8dd1\u901a\u6bd4\u5b8c\u7f8e\u7ea6\u675f\u91cd\u8981<\/li>\n<\/ul>\n<p>\u5982\u679c\u60f3\u8ddf\u7740\u672c\u8bfe\u6f14\u793a\u7684\u6d41\u7a0b\u8d70&#xff0c;\u5148\u5f80\u8868\u91cc\u63d2\u4e24\u6761\u79cd\u5b50\u6570\u636e&#xff1a;<\/p>\n<p><span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> <span class=\"token keyword\">user<\/span> <span class=\"token punctuation\">(<\/span>name<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">VALUES<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;zhangsan&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;lisi&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">INSERT<\/span> <span class=\"token keyword\">INTO<\/span> todo <span class=\"token punctuation\">(<\/span>user_id<span class=\"token punctuation\">,<\/span> title<span class=\"token punctuation\">,<\/span> done<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">VALUES<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\u5b66\u7b2c 15 \u8bfe&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\u5199\u6559\u7a0b\u4ee3\u7801&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\u4e70\u725b\u5976&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u63d2\u5b8c\u540e\u624b\u52a8\u67e5\u4e00\u4e0b\u786e\u8ba4&#xff1a;<\/p>\n<p>mysql&gt; SELECT * FROM user;<br \/>\nid      name<br \/>\n2       lisi<br \/>\n1       zhangsan<\/p>\n<p>mysql&gt; SELECT * FROM todo;<br \/>\nid      user_id title           done<br \/>\n1       1       \u5b66\u7b2c 15 \u8bfe      0<br \/>\n2       1       \u5199\u6559\u7a0b\u4ee3\u7801      1<br \/>\n3       2       \u4e70\u725b\u5976          0<\/p>\n<hr \/>\n<h3>\u4e09\u3001Model \u7c7b&#xff1a;\u7eaf\u6570\u636e\u642c\u8fd0\u5de5<\/h3>\n<p>Model \u5c42\u53ea\u505a\u4e00\u4ef6\u4e8b&#xff1a;\u628a\u6570\u636e\u5e93\u91cc\u7684\u4e00\u884c\u6570\u636e\u642c\u5230\u5185\u5b58\u91cc&#xff0c;\u53d8\u6210\u4e00\u4e2a\u53ef\u4ee5\u5728\u7a0b\u5e8f\u91cc\u81ea\u7531\u4f20\u9012\u7684\u5bf9\u8c61\u3002\u5b83\u4e0d\u78b0\u6570\u636e\u5e93\u3001\u4e0d\u505a\u4e1a\u52a1\u51b3\u7b56\u3002<\/p>\n<p>class User {<br \/>\n    let id: Int64<br \/>\n    let name: String<br \/>\n    init(id: Int64, name: String) {<br \/>\n        this.id &#061; id<br \/>\n        this.name &#061; name<br \/>\n    }<br \/>\n}<\/p>\n<p>class Todo {<br \/>\n    let id: Int64<br \/>\n    let userId: Int64<br \/>\n    let title: String<br \/>\n    var done: Bool<br \/>\n    init(id: Int64, userId: Int64, title: String, done: Bool) {<br \/>\n        this.id &#061; id<br \/>\n        this.userId &#061; userId<br \/>\n        this.title &#061; title<br \/>\n        this.done &#061; done<br \/>\n    }<br \/>\n}<\/p>\n<p>\u8fd9\u4e24\u4e2a\u7c7b\u7684\u5199\u6cd5\u548c\u7b2c 14 \u8bfe Account \u7c7b\u5b8c\u5168\u4e00\u81f4&#xff1a;let \u8868\u793a\u521b\u5efa\u540e\u4e0d\u53d8&#xff08;User \u7684 id\u3001name \u521b\u5efa\u540e\u4e0d\u8be5\u53d8&#xff1b;Todo \u7684 id\u3001userId\u3001title \u540c\u7406&#xff09;&#xff0c;var \u8868\u793a\u53ef\u4ee5\u6539&#xff08;Todo \u7684 done \u53ef\u4ee5\u4ece\u672a\u5b8c\u6210\u53d8\u5b8c\u6210&#xff09;\u3002<\/p>\n<p>Model \u5c42\u7684\u8bbe\u8ba1\u539f\u5219&#xff1a;\u8d8a\u8584\u8d8a\u597d\u3002\u522b\u5728\u91cc\u9762\u5199\u4efb\u4f55 SQL\u3001\u4efb\u4f55\u4e1a\u52a1\u5224\u65ad&#xff0c;\u4fdd\u6301\u7eaf\u7cb9\u7684\u6570\u636e\u5bb9\u5668\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u4e24\u4e2a DAO&#xff1a;\u5355\u8868\u64cd\u4f5c\u7684\u5957\u8def<\/h3>\n<p>Data Access Object&#xff08;DAO&#xff09;\u5c42\u53ea\u8d1f\u8d23\u4e00\u4ef6\u4e8b&#xff1a;\u628a SQL \u8bed\u53e5\u7ffb\u8bd1\u6210 DAO \u65b9\u6cd5\u3002\u4e00\u5f20\u8868\u5bf9\u5e94\u4e00\u4e2a DAO \u7c7b&#xff0c;\u6bcf\u4e2a\u65b9\u6cd5\u4ee3\u8868\u4e00\u6761\u53ef\u88ab\u590d\u7528\u7684 SQL\u3002<\/p>\n<h4>UserDao<\/h4>\n<p>class UserDao {<br \/>\n    let conn: Connection<br \/>\n    init(conn: Connection) { this.conn &#061; conn }<\/p>\n<p>    \/\/ \u6309\u540d\u5b57\u67e5\u7528\u6237&#xff08;\u767b\u5f55\u573a\u666f\u5e38\u7528&#xff09;<br \/>\n    func findByName(name: String): ?User {<br \/>\n        let stmt &#061; conn.prepareStatement(&#034;SELECT id, name FROM user WHERE name &#061; ?&#034;)<br \/>\n        stmt.set(1, name)<br \/>\n        let rs &#061; stmt.query()<br \/>\n        var result: ?User &#061; None<br \/>\n        if (rs.next()) {<br \/>\n            result &#061; Some(User(rs.get&lt;Int64&gt;(1), rs.get&lt;String&gt;(2)))<br \/>\n        }<br \/>\n        rs.close()<br \/>\n        stmt.close()<br \/>\n        return result<br \/>\n    }<\/p>\n<p>    \/\/ \u65b0\u5efa\u7528\u6237&#xff0c;\u8fd4\u56de\u65b0\u7528\u6237\u7684 id<br \/>\n    func insert(name: String): Int64 {<br \/>\n        let stmt &#061; conn.prepareStatement(&#034;INSERT INTO user (name) VALUES (?)&#034;)<br \/>\n        stmt.set(1, name)<br \/>\n        let r &#061; stmt.update()<br \/>\n        stmt.close()<br \/>\n        return r.lastInsertId<br \/>\n    }<br \/>\n}<\/p>\n<h4>TodoDao<\/h4>\n<p>class TodoDao {<br \/>\n    let conn: Connection<br \/>\n    init(conn: Connection) { this.conn &#061; conn }<\/p>\n<p>    \/\/ \u6309 id \u67e5\u5355\u6761 Todo<br \/>\n    func findById(id: Int64): ?Todo {<br \/>\n        let stmt &#061; conn.prepareStatement(<br \/>\n            &#034;SELECT id, user_id, title, done FROM todo WHERE id &#061; ?&#034;)<br \/>\n        stmt.set(1, id)<br \/>\n        let rs &#061; stmt.query()<br \/>\n        var result: ?Todo &#061; None<br \/>\n        if (rs.next()) {<br \/>\n            let rawDone &#061; rs.get&lt;Int64&gt;(4)<br \/>\n            let doneFlag: Bool &#061; rawDone !&#061; 0<br \/>\n            result &#061; Some(Todo(rs.get&lt;Int64&gt;(1), rs.get&lt;Int64&gt;(2),<br \/>\n                               rs.get&lt;String&gt;(3), doneFlag))<br \/>\n        }<br \/>\n        rs.close()<br \/>\n        stmt.close()<br \/>\n        return result<br \/>\n    }<\/p>\n<p>    \/\/ \u5217\u51fa\u67d0\u7528\u6237\u7684\u5168\u90e8 Todo<br \/>\n    func listByUser(userId: Int64): Array&lt;Todo&gt; {<br \/>\n        let stmt &#061; conn.prepareStatement(<br \/>\n            &#034;SELECT id, user_id, title, done FROM todo WHERE user_id &#061; ? ORDER BY id&#034;)<br \/>\n        stmt.set(1, userId)<br \/>\n        let rs &#061; stmt.query()<br \/>\n        let list &#061; ArrayList&lt;Todo&gt;()<br \/>\n        while (rs.next()) {<br \/>\n            let rawDone &#061; rs.get&lt;Int64&gt;(4)<br \/>\n            let doneFlag: Bool &#061; rawDone !&#061; 0<br \/>\n            list.add(Todo(rs.get&lt;Int64&gt;(1), rs.get&lt;Int64&gt;(2),<br \/>\n                          rs.get&lt;String&gt;(3), doneFlag))<br \/>\n        }<br \/>\n        rs.close()<br \/>\n        stmt.close()<br \/>\n        return list.toArray()<br \/>\n    }<\/p>\n<p>    \/\/ \u7ed9\u67d0\u7528\u6237\u52a0\u4e00\u6761 Todo&#xff0c;\u8fd4\u56de\u65b0 Todo \u7684 id<br \/>\n    func insert(userId: Int64, title: String): Int64 {<br \/>\n        let stmt &#061; conn.prepareStatement(<br \/>\n            &#034;INSERT INTO todo (user_id, title, done) VALUES (?, ?, 0)&#034;)<br \/>\n        stmt.set(1, userId)<br \/>\n        stmt.set(2, title)<br \/>\n        let r &#061; stmt.update()<br \/>\n        stmt.close()<br \/>\n        return r.lastInsertId<br \/>\n    }<\/p>\n<p>    \/\/ \u628a\u67d0\u6761 Todo \u6807\u8bb0\u4e3a\u5df2\u5b8c\u6210 \/ \u672a\u5b8c\u6210<br \/>\n    func setDone(id: Int64, done: Bool): Int64 {<br \/>\n        let stmt &#061; conn.prepareStatement(&#034;UPDATE todo SET done &#061; ? WHERE id &#061; ?&#034;)<br \/>\n        var flag: Int64 &#061; 0<br \/>\n        if (done) {<br \/>\n            flag &#061; 1<br \/>\n        }<br \/>\n        stmt.set(1, flag)<br \/>\n        stmt.set(2, id)<br \/>\n        let rows &#061; stmt.update().rowCount<br \/>\n        stmt.close()<br \/>\n        return rows<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u67d0\u6761 Todo<br \/>\n    func deleteById(id: Int64): Int64 {<br \/>\n        let stmt &#061; conn.prepareStatement(&#034;DELETE FROM todo WHERE id &#061; ?&#034;)<br \/>\n        stmt.set(1, id)<br \/>\n        let rows &#061; stmt.update().rowCount<br \/>\n        stmt.close()<br \/>\n        return rows<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u67d0\u7528\u6237\u7684\u5168\u90e8 Todo&#xff08;**\u53ea\u5728\u4e8b\u52a1\u91cc\u7528**&#xff09;<br \/>\n    func deleteByUserId(userId: Int64): Int64 {<br \/>\n        let stmt &#061; conn.prepareStatement(&#034;DELETE FROM todo WHERE user_id &#061; ?&#034;)<br \/>\n        stmt.set(1, userId)<br \/>\n        let rows &#061; stmt.update().rowCount<br \/>\n        stmt.close()<br \/>\n        return rows<br \/>\n    }<br \/>\n}<\/p>\n<h4>DAO \u5c42\u7684\u4e09\u4e2a\u5957\u8def<\/h4>\n<li>\u6240\u6709 SQL \u8d70 conn.prepareStatement&#xff08;\u9884\u7f16\u8bd1&#xff09;&#xff0c;\u7edd\u4e0d\u7528\u5b57\u7b26\u4e32\u62fc\u63a5\u3002\u7b2c 12 \u8bfe\u8bb2\u8fc7\u539f\u56e0&#xff1a;\u9632 SQL \u6ce8\u5165<\/li>\n<li>Connection \u662f DAO \u7684\u552f\u4e00\u4f9d\u8d56&#xff0c;\u901a\u8fc7\u6784\u9020\u5668\u6ce8\u5165&#xff08;init(conn: Connection)&#xff09;\u3002Service \u5c42\u4f20\u7ed9 DAO \u7684\u662f\u540c\u4e00\u4e2a\u8fde\u63a5&#xff0c;\u4e8b\u52a1\u91cc\u6240\u6709 DAO \u8c03\u7528\u81ea\u7136\u5171\u4eab\u540c\u4e00\u4e2a\u4e8b\u52a1\u72b6\u6001<\/li>\n<li>ResultSet \u548c Statement \u7528\u5b8c\u7acb\u523b close\u3002\u4e0d close \u867d\u7136\u7a0b\u5e8f\u4e0d\u5d29&#xff0c;\u4f46\u6570\u636e\u5e93\u670d\u52a1\u7aef\u4f1a\u4fdd\u6301\u8fde\u63a5\u6570\u4e0d\u91ca\u653e&#xff0c;\u8dd1\u4e45\u4e86 MySQL \u4f1a\u6ee1<\/li>\n<hr \/>\n<h3>\u4e94\u3001Service \u5c42&#xff1a;\u628a DAO \u4e32\u6210\u4e1a\u52a1<\/h3>\n<p>DAO \u53ea\u7ba1\u5355\u8868\u64cd\u4f5c&#xff0c;\u4f46\u771f\u5b9e\u4e1a\u52a1\u7ecf\u5e38\u8de8\u591a\u5f20\u8868\u3002\u6bd4\u5982&#034;\u5220\u9664\u7528\u6237&#034;\u8fd9\u4ef6\u4e8b&#xff1a;\u5220 user \u8868\u4e4b\u524d\u5fc5\u987b\u5148\u5220\u5149\u4ed6\u6240\u6709\u7684 todo&#xff0c;\u5426\u5219\u4f1a\u51fa\u73b0&#034;\u5b64\u513f todo&#034;\u3002\u8fd9\u79cd\u8de8\u8868\u7f16\u6392\u2014\u2014\u4e8b\u52a1\u2014\u2014 \u5c31\u662f Service \u5c42\u7684\u804c\u8d23\u3002<\/p>\n<p>class TodoService {<br \/>\n    let userDao: UserDao<br \/>\n    let todoDao: TodoDao<br \/>\n    let conn: Connection<\/p>\n<p>    init(conn: Connection) {<br \/>\n        this.conn &#061; conn<br \/>\n        this.userDao &#061; UserDao(conn)<br \/>\n        this.todoDao &#061; TodoDao(conn)<br \/>\n    }<\/p>\n<p>    \/\/ \u521b\u5efa\u7528\u6237&#xff1b;\u540c\u540d\u5df2\u5b58\u5728\u5219\u76f4\u63a5\u8fd4\u56de&#xff0c;\u4e0d\u91cd\u590d\u63d2<br \/>\n    func createUser(name: String): User {<br \/>\n        let found &#061; userDao.findByName(name)<br \/>\n        if (found.isSome()) {<br \/>\n            return found.getOrThrow()<br \/>\n        }<br \/>\n        let id &#061; userDao.insert(name)<br \/>\n        return User(id, name)<br \/>\n    }<\/p>\n<p>    \/\/ \u7ed9\u7528\u6237\u52a0\u4e00\u6761 Todo&#xff1b;\u7528\u6237\u4e0d\u5b58\u5728\u8fd4\u56de None<br \/>\n    func addTodo(userName: String, title: String): ?Int64 {<br \/>\n        let found &#061; userDao.findByName(userName)<br \/>\n        if (found.isNone()) {<br \/>\n            println(&#034;\u7528\u6237 ${userName} \u4e0d\u5b58\u5728&#034;)<br \/>\n            return None<br \/>\n        }<br \/>\n        let userId &#061; found.getOrThrow().id<br \/>\n        return Some(todoDao.insert(userId, title))<br \/>\n    }<\/p>\n<p>    \/\/ \u628a\u67d0\u6761 Todo \u6807\u4e3a\u5df2\u5b8c\u6210<br \/>\n    func completeTodo(todoId: Int64): Bool {<br \/>\n        let found &#061; todoDao.findById(todoId)<br \/>\n        if (found.isNone()) {<br \/>\n            println(&#034;todo ${todoId} \u4e0d\u5b58\u5728&#034;)<br \/>\n            return false<br \/>\n        }<br \/>\n        return todoDao.setDone(todoId, true) &gt; 0<br \/>\n    }<\/p>\n<p>    \/\/ \u5220\u9664\u4e00\u6761 Todo<br \/>\n    func deleteTodo(todoId: Int64): Bool {<br \/>\n        let found &#061; todoDao.findById(todoId)<br \/>\n        if (found.isNone()) {<br \/>\n            println(&#034;todo ${todoId} \u4e0d\u5b58\u5728&#034;)<br \/>\n            return false<br \/>\n        }<br \/>\n        return todoDao.deleteById(todoId) &gt; 0<br \/>\n    }<\/p>\n<p>    \/\/ \u5217\u51fa\u67d0\u7528\u6237\u5168\u90e8 Todo<br \/>\n    func listUserTodos(userName: String): ?(User, Array&lt;Todo&gt;) {<br \/>\n        let found &#061; userDao.findByName(userName)<br \/>\n        if (found.isNone()) {<br \/>\n            return None<br \/>\n        }<br \/>\n        let u &#061; found.getOrThrow()<br \/>\n        return Some((u, todoDao.listByUser(u.id)))<br \/>\n    }<\/p>\n<p>    \/\/ \u4e8b\u52a1&#xff1a;\u5220\u7528\u6237 &#043; \u5220\u5149\u4ed6\u7684 Todo<br \/>\n    \/\/ \u4e24\u6761 SQL \u8981\u4e48\u4e00\u8d77\u6210&#xff0c;\u8981\u4e48\u4e00\u8d77\u4e0d\u7b97<br \/>\n    func deleteUserAndTodos(userName: String): Bool {<br \/>\n        let found &#061; userDao.findByName(userName)<br \/>\n        if (found.isNone()) {<br \/>\n            println(&#034;\u7528\u6237 ${userName} \u4e0d\u5b58\u5728&#034;)<br \/>\n            return false<br \/>\n        }<br \/>\n        let u &#061; found.getOrThrow()<br \/>\n        let tx &#061; conn.createTransaction()<br \/>\n        tx.begin()<br \/>\n        try {<br \/>\n            \/\/ \u5148\u5220 todo&#xff08;user \u8868\u6ca1\u6709\u5176\u4ed6\u8868\u4f9d\u8d56\u5b83&#xff0c;\u987a\u5e8f\u4e0d\u654f\u611f&#xff09;<br \/>\n            todoDao.deleteByUserId(u.id)<br \/>\n            let stmt &#061; conn.prepareStatement(&#034;DELETE FROM user WHERE id &#061; ?&#034;)<br \/>\n            stmt.set(1, u.id)<br \/>\n            stmt.update()<br \/>\n            stmt.close()<br \/>\n            tx.commit()<br \/>\n            return true<br \/>\n        } catch (e: SqlException) {<br \/>\n            tx.rollback()<br \/>\n            println(&#034;\u5220\u9664\u7528\u6237\u56de\u6eda&#xff1a;${e.message}&#034;)<br \/>\n            return false<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u4e8b\u52a1\u7248 deleteUserAndTodos \u62c6\u89e3<\/h4>\n<p>\u8fd9\u662f\u7b2c 13 \u8bfe\u4e8b\u52a1\u4e09\u4ef6\u5957\u7684\u6807\u51c6\u7528\u6cd5&#xff1a;<\/p>\n<table>\n<tr>\u6b65\u9aa4\u4ee3\u7801\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>\u9886\u4e8b\u52a1<\/td>\n<td>let tx &#061; conn.createTransaction()<\/td>\n<td>\u4ece\u8fde\u63a5\u9886\u4e00\u4e2a\u4e8b\u52a1\u5bf9\u8c61&#xff08;\u5b83\u53ea\u662f\u4e00\u5c42\u72b6\u6001\u6807\u8bb0&#xff0c;\u6ca1\u5f00\u65b0\u8fde\u63a5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u59cb<\/td>\n<td>tx.begin()<\/td>\n<td>\u4e4b\u540e\u8fd9\u4e2a\u8fde\u63a5\u4e0a\u6267\u884c\u7684\u6240\u6709\u6539\u52a8\u90fd\u8fdb\u8349\u7a3f\u533a<\/td>\n<\/tr>\n<tr>\n<td>\u5e72\u6d3b<\/td>\n<td>todoDao.deleteByUserId &#043; conn.prepareStatement(&#034;DELETE FROM user&#8230;&#034;)<\/td>\n<td>\u4e24\u6761 SQL&#xff1b;\u6ce8\u610f&#xff1a;\u4ecd\u7136\u8d70 conn.prepareStatement&#xff0c;\u4e0d\u662f tx.prepareStatement&#xff08;\u7b2c 13 \u8bfe\u5b9e\u6d4b\u7ed3\u8bba&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u63d0\u4ea4<\/td>\n<td>tx.commit()<\/td>\n<td>\u8349\u7a3f\u5168\u90e8\u843d\u5e93&#xff0c;\u4e8b\u52a1\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td>\u5f02\u5e38\u56de\u6eda<\/td>\n<td>catch (e: SqlException) { tx.rollback() }<\/td>\n<td>\u8349\u7a3f\u5168\u90e8\u6495\u6389&#xff0c;\u4e8b\u52a1\u7ed3\u675f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5c0f\u63d0\u793a&#xff1a;\u5148\u5220 todo \u8fd8\u662f\u5148\u5220 user&#xff1f;\u4e24\u79cd\u987a\u5e8f\u90fd\u884c\u2014\u2014\u6211\u4eec\u6ca1\u52a0\u5916\u952e\u7ea6\u675f&#xff0c;\u6240\u4ee5\u4e0d\u7528\u6015&#034;\u5220\u4e86\u7236\u8868\u518d\u5220\u5b50\u8868&#034;\u7684\u95ee\u9898\u3002\u4f46\u771f\u5b9e\u751f\u4ea7\u91cc\u52a0\u4e86\u5916\u952e\u7ea6\u675f\u540e\u5fc5\u987b\u5148\u5220\u5b50\u8868&#xff08;todo&#xff09;\u3002\u517b\u6210\u5148\u5220\u4f9d\u8d56\u65b9\u7684\u4e60\u60ef\u4e0d\u5403\u4e8f\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001main&#xff1a;\u4e00\u6761\u5b8c\u6574\u7684\u4e1a\u52a1\u6d41\u7a0b<\/h3>\n<p>main \u51fd\u6570\u5c31\u662f\u4e00\u4e2a\u821e\u53f0\u2014\u2014\u5b83\u628a\u524d\u9762\u51c6\u5907\u597d\u7684\u4e00\u5207\u6f14\u5458&#xff08;Connection\u3001Service&#xff09;\u62c9\u4e0a\u53f0&#xff0c;\u6309\u987a\u5e8f\u8d70\u4e00\u904d\u5267\u60c5\u3002\u540c\u65f6\u8fd8\u6709\u4e00\u4e2a\u8f85\u52a9\u51fd\u6570 printUserTodos \u4e13\u95e8\u8d1f\u8d23&#034;\u683c\u5f0f\u5316\u6253\u5370\u67d0\u7528\u6237\u7684 Todo \u5217\u8868&#034;&#xff1a;<\/p>\n<p>func printUserTodos(svc: TodoService, userName: String): Unit {<br \/>\n    let found &#061; svc.listUserTodos(userName)<br \/>\n    if (found.isNone()) {<br \/>\n        println(&#034;${userName} \u4e0d\u5b58\u5728&#034;)<br \/>\n        return<br \/>\n    }<br \/>\n    let (user, todos) &#061; found.getOrThrow()<br \/>\n    println(&#034;\u7528\u6237 ${user.name}&#xff08;\u5171 ${todos.size} \u6761 Todo&#xff09;&#xff1a;&#034;)<br \/>\n    for (t in todos) {<br \/>\n        var mark: String &#061; &#034; &#034;<br \/>\n        if (t.done) {<br \/>\n            mark &#061; &#034;\u2713&#034;<br \/>\n        }<br \/>\n        println(&#034;  [${mark}] #${t.id} ${t.title}&#034;)<br \/>\n    }<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    let driver &#061; DriverManager.getDriver(&#034;mariadb&#034;).getOrThrow()<br \/>\n    let ds &#061; driver.open(&#034;mariadb:\/\/127.0.0.1:3306&#034;, [<br \/>\n        (&#034;username&#034;, &#034;root&#034;),<br \/>\n        (&#034;password&#034;, &#034;wangpeng&#034;),<br \/>\n        (&#034;database&#034;, &#034;todo_tutorial&#034;)<br \/>\n    ])<br \/>\n    let conn &#061; ds.connect()<br \/>\n    let svc &#061; TodoService(conn)<\/p>\n<p>    println(&#034;&#061;&#061;&#061; 1. \u5217\u51fa zhangsan \u5f53\u524d\u7684 Todo &#061;&#061;&#061;&#034;)<br \/>\n    printUserTodos(svc, &#034;zhangsan&#034;)<\/p>\n<p>    println(&#034;&#034;)<br \/>\n    println(&#034;&#061;&#061;&#061; 2. \u628a zhangsan \u7684 #1&#xff08;\u5b66\u7b2c 15 \u8bfe&#xff09;\u6807\u4e3a\u5df2\u5b8c\u6210 &#061;&#061;&#061;&#034;)<br \/>\n    if (svc.completeTodo(1)) {<br \/>\n        println(&#034;#1 \u5df2\u5b8c\u6210&#034;)<br \/>\n    } else {<br \/>\n        println(&#034;#1 \u4e0d\u5b58\u5728&#034;)<br \/>\n    }<\/p>\n<p>    println(&#034;&#034;)<br \/>\n    println(&#034;&#061;&#061;&#061; 3. \u518d\u5217 zhangsan \u7684 Todo&#xff0c;#1 \u5e94\u8be5\u5e26 \u2713 &#061;&#061;&#061;&#034;)<br \/>\n    printUserTodos(svc, &#034;zhangsan&#034;)<\/p>\n<p>    println(&#034;&#034;)<br \/>\n    println(&#034;&#061;&#061;&#061; 4. \u65b0\u5efa\u7528\u6237 zhaoliu \u5e76\u52a0 3 \u6761 Todo &#061;&#061;&#061;&#034;)<br \/>\n    let u &#061; svc.createUser(&#034;zhaoliu&#034;)<br \/>\n    println(&#034;\u521b\u5efa\u7528\u6237\u6210\u529f&#xff1a;id&#061;${u.id}, name&#061;${u.name}&#034;)<br \/>\n    svc.addTodo(&#034;zhaoliu&#034;, &#034;\u8dd1\u6b65 3 \u516c\u91cc&#034;)<br \/>\n    svc.addTodo(&#034;zhaoliu&#034;, &#034;\u80cc\u5355\u8bcd 50 \u4e2a&#034;)<br \/>\n    svc.addTodo(&#034;zhaoliu&#034;, &#034;\u8bfb\u4e00\u7ae0\u5c0f\u8bf4&#034;)<\/p>\n<p>    println(&#034;&#034;)<br \/>\n    println(&#034;&#061;&#061;&#061; 5. \u5217\u51fa\u5168\u90e8 zhaoliu Todo &#061;&#061;&#061;&#034;)<br \/>\n    printUserTodos(svc, &#034;zhaoliu&#034;)<\/p>\n<p>    println(&#034;&#034;)<br \/>\n    println(&#034;&#061;&#061;&#061; 6. \u5220\u9664 lisi &#043; \u4ed6\u7684\u5168\u90e8 Todo&#xff08;\u4e8b\u52a1&#xff09; &#061;&#061;&#061;&#034;)<br \/>\n    if (svc.deleteUserAndTodos(&#034;lisi&#034;)) {<br \/>\n        println(&#034;lisi \u8fde\u540c Todo \u5df2\u5168\u90e8\u5220\u9664&#034;)<br \/>\n    } else {<br \/>\n        println(&#034;\u5220\u9664\u5931\u8d25&#034;)<br \/>\n    }<br \/>\n    if (svc.listUserTodos(&#034;lisi&#034;).isNone()) {<br \/>\n        println(&#034;\u786e\u8ba4&#xff1a;lisi \u5df2\u4e0d\u5b58\u5728&#034;)<br \/>\n    } else {<br \/>\n        println(&#034;\u8b66\u544a&#xff1a;lisi \u8fd8\u5b58\u5728&#xff01;&#034;)<br \/>\n    }<\/p>\n<p>    conn.close()<br \/>\n    0<br \/>\n}<\/p>\n<p>\u6ce8\u610f&#xff1a;import mariadb.cdbc \u867d\u7136\u6211\u4eec\u6ca1\u5728\u4ee3\u7801\u91cc\u663e\u5f0f\u8c03\u7528\u5b83\u7684\u7c7b&#xff0c;\u4f46\u5fc5\u987b import\u2014\u2014\u8fd9\u4f1a\u89e6\u53d1\u9a71\u52a8\u5305\u7684\u81ea\u6ce8\u518c&#xff08;\u7b2c 07 \u8bfe\u6838\u5fc3\u673a\u5236&#xff09;&#xff0c;\u8ba9 DriverManager.getDriver(&#034;mariadb&#034;) \u80fd\u627e\u5230 mariadb \u9a71\u52a8\u3002\u6f0f\u5199\u4e86 getDriver \u8fd4\u56de None&#xff0c;getOrThrow() \u5f53\u573a\u5d29\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u8fd0\u884c\u8f93\u51fa&#xff08;cjpm run \u9010\u5b57\u6bd4\u5bf9&#xff09;<\/h3>\n<p>\u8dd1 cjpm run&#xff1a;<\/p>\n<p>&#061;&#061;&#061; 1. \u5217\u51fa zhangsan \u5f53\u524d\u7684 Todo &#061;&#061;&#061;<br \/>\n\u7528\u6237 zhangsan&#xff08;\u5171 2 \u6761 Todo&#xff09;&#xff1a;<br \/>\n  [ ] #1 \u5b66\u7b2c 15 \u8bfe<br \/>\n  [\u2713] #2 \u5199\u6559\u7a0b\u4ee3\u7801<\/p>\n<p>&#061;&#061;&#061; 2. \u628a zhangsan \u7684 #1&#xff08;\u5b66\u7b2c 15 \u8bfe&#xff09;\u6807\u4e3a\u5df2\u5b8c\u6210 &#061;&#061;&#061;<br \/>\n#1 \u5df2\u5b8c\u6210<\/p>\n<p>&#061;&#061;&#061; 3. \u518d\u5217 zhangsan \u7684 Todo&#xff0c;#1 \u5e94\u8be5\u5e26 \u2713 &#061;&#061;&#061;<br \/>\n\u7528\u6237 zhangsan&#xff08;\u5171 2 \u6761 Todo&#xff09;&#xff1a;<br \/>\n  [\u2713] #1 \u5b66\u7b2c 15 \u8bfe<br \/>\n  [\u2713] #2 \u5199\u6559\u7a0b\u4ee3\u7801<\/p>\n<p>&#061;&#061;&#061; 4. \u65b0\u5efa\u7528\u6237 zhaoliu \u5e76\u52a0 3 \u6761 Todo &#061;&#061;&#061;<br \/>\n\u521b\u5efa\u7528\u6237\u6210\u529f&#xff1a;id&#061;3, name&#061;zhaoliu<\/p>\n<p>&#061;&#061;&#061; 5. \u5217\u51fa\u5168\u90e8 zhaoliu Todo &#061;&#061;&#061;<br \/>\n\u7528\u6237 zhaoliu&#xff08;\u5171 3 \u6761 Todo&#xff09;&#xff1a;<br \/>\n  [ ] #4 \u8dd1\u6b65 3 \u516c\u91cc<br \/>\n  [ ] #5 \u80cc\u5355\u8bcd 50 \u4e2a<br \/>\n  [ ] #6 \u8bfb\u4e00\u7ae0\u5c0f\u8bf4<\/p>\n<p>&#061;&#061;&#061; 6. \u5220\u9664 lisi &#043; \u4ed6\u7684\u5168\u90e8 Todo&#xff08;\u4e8b\u52a1&#xff09; &#061;&#061;&#061;<br \/>\nlisi \u8fde\u540c Todo \u5df2\u5168\u90e8\u5220\u9664<br \/>\n\u786e\u8ba4&#xff1a;lisi \u5df2\u4e0d\u5b58\u5728<\/p>\n<p>cjpm run finished<\/p>\n<p>\u4e3a\u4ec0\u4e48\u6bcf\u6b21\u8fd0\u884c\u524d\u8981 reset \u6570\u636e\u5e93&#xff1f; \u56e0\u4e3a step 4 \u65b0\u5efa\u7528\u6237\u540e\u4e0d\u4f1a\u81ea\u52a8\u5220\u9664&#xff1b;step 6 \u5220\u4e86 lisi&#xff1b;\u7b2c\u4e8c\u6b21\u8fd0\u884c\u65f6 seed \u6570\u636e&#xff08;zhangsan\u3001lisi\u3001#1 #2 #3 todo&#xff09;\u5df2\u7ecf\u4e0d\u5b58\u5728\u4e86&#xff0c;listUserTodos(&#034;zhangsan&#034;) \u4f1a\u62a5&#034;zhangsan \u4e0d\u5b58\u5728&#034;\u3002\u751f\u4ea7\u7a0b\u5e8f\u4e0d\u4f1a\u6bcf\u6b21\u90fd\u91cd\u7f6e\u2014\u2014\u8fd9\u662f\u6559\u5b66\u6f14\u793a\u7684\u4fbf\u5229&#xff0c;\u8ba9\u4f60\u80fd\u53cd\u590d\u770b\u540c\u4e00\u6bb5\u8f93\u51fa\u3002<\/p>\n<hr \/>\n<h3>\u516b\u3001\u5e38\u89c1\u62a5\u9519\u901f\u89c8&#xff08;\u6211\u5b9e\u6d4b\u8e29\u7684\u5751&#xff09;<\/h3>\n<h4>1. NoneValueException \u5728 DriverManager.getDriver(&#034;mariadb&#034;).getOrThrow()<\/h4>\n<p>\u539f\u56e0&#xff1a;\u6f0f\u5199 import mariadb.cdbc\u3002mariadb \u9a71\u52a8\u5305\u7684\u81ea\u6ce8\u518c\u673a\u5236\u9700\u8981 import \u624d\u80fd\u89e6\u53d1&#xff1b;\u4e0d import&#xff0c;DriverManager \u91cc\u5c31\u6ca1\u6709 mariadb \u8fd9\u4e2a\u9a71\u52a8&#xff0c;getDriver \u8fd4\u56de None\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;\u5728\u6587\u4ef6\u9876\u90e8\u8865\u4e0a import mariadb.cdbc\u3002<\/p>\n<h4>2. error: &#039;append&#039; is not a member of struct &#039;Array&lt;T&gt;&#039;<\/h4>\n<p>\u539f\u56e0&#xff1a;\u4f60\u628a Array \u5f53\u6210\u4e86\u52a8\u6001\u6570\u7ec4&#xff0c;\u7528 .append() \u5f80\u91cc\u52a0\u5143\u7d20\u3002\u4ed3\u9889 SDK 1.2.0 \u7684 Array \u662f\u56fa\u5b9a\u957f\u5ea6\u6570\u7ec4&#xff0c;\u6ca1\u6709\u589e\u5220\u65b9\u6cd5\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;\u7528 ArrayList&lt;T&gt;&#xff08;import std.collection.ArrayList&#xff09;&#xff0c;\u8ffd\u52a0\u7528 .add()&#xff0c;\u52a8\u6001\u96c6\u5408\u7528\u5b8c\u53ef\u4ee5 .toArray() \u8f6c\u56de\u56fa\u5b9a\u957f\u5ea6\u6570\u7ec4\u3002<\/p>\n<h4>3. error: variable &#039;xxx&#039; is immutable<\/h4>\n<p>\u539f\u56e0&#xff1a;let \u58f0\u660e\u7684\u53d8\u91cf\u4f60\u53c8\u8d4b\u4e86\u65b0\u503c\u3002\u6bd4\u5982 let flag &#061; 0 \u4e4b\u540e if (done) flag &#061; 1\u2014\u2014flag \u5fc5\u987b\u7528 var\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;\u9700\u8981\u4fee\u6539\u7684\u53d8\u91cf\u4e00\u5f8b var&#xff0c;\u4e0d\u9700\u8981\u6539\u7684\u4fdd\u6301 let&#xff08;\u7f16\u8bd1\u5668\u4f1a\u5e2e\u4f60\u53d1\u73b0\u610f\u5916\u4fee\u6539&#xff09;\u3002<\/p>\n<h4>4. \u4e8b\u52a1\u91cc\u5199 tx.prepareStatement(&#8230;) \u7f16\u8bd1\u62a5\u9519<\/h4>\n<p>\u539f\u56e0&#xff1a;Transaction \u63a5\u53e3\u6ca1\u6709 prepareStatement \u65b9\u6cd5\u3002\u4e8b\u52a1\u53ea\u662f\u4e00\u5c42&#034;\u8349\u7a3f\u533a\u72b6\u6001&#034;&#xff0c;\u4ece begin() \u5230 commit() \/ rollback() \u4e4b\u95f4&#xff0c;\u8fd9\u4e2a\u8fde\u63a5\u4e0a\u6267\u884c\u7684\u6240\u6709\u6539\u52a8\u81ea\u52a8\u8fdb\u5165\u8349\u7a3f\u533a\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;\u4e8b\u52a1\u91cc\u6267\u884c SQL \u4ecd\u7136\u8d70 conn.prepareStatement\u2014\u2014\u548c\u4e8b\u52a1\u5916\u4e00\u6a21\u4e00\u6837\u7684\u4ee3\u7801&#xff0c;\u53ea\u662f\u56e0\u4e3a begin() \u5df2\u7ecf\u628a\u8fde\u63a5\u6807\u8bb0\u6210&#034;\u4e8b\u52a1\u6a21\u5f0f&#034;\u4e86\u3002\u7b2c 13 \u8bfe\u6709\u5b9e\u6d4b\u7ed3\u8bba\u3002<\/p>\n<h4>5. error: generic type should be used with type argument &#043; error: &#039;get&#039; is not a member of enum &#039;Option&lt;T&gt;&#039;<\/h4>\n<p>\u539f\u56e0&#xff1a;Option \u7684\u5224\u65ad\u548c\u89e3\u5305\u4f60\u53ef\u80fd\u7528\u4e86\u9519\u8bef\u65b9\u6cd5\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;<\/p>\n<ul>\n<li>\u5224\u65ad\u6709\u503c&#xff1a;.isSome() \/ .isNone()<\/li>\n<li>\u89e3\u5305\u53d6\u503c&#xff1a;.getOrThrow()&#xff08;\u6709\u503c\u8fd4\u56de\u503c&#xff0c;\u6ca1\u503c\u629b\u5f02\u5e38&#xff09;<\/li>\n<li>\u4e0d\u80fd\u5199 found &#061;&#061; None&#xff08;\u7f16\u8bd1\u5668\u8ba4\u4e3a None \u662f\u6cdb\u578b\u5360\u4f4d\u7b26&#xff0c;\u4e0d\u662f\u5177\u4f53\u503c&#xff09;<\/li>\n<\/ul>\n<h4>6. ResultSet \u7528\u5b8c\u6ca1 close \u4e5f\u80fd\u8dd1&#xff0c;\u4f46\u8dd1\u591a\u4e86 MySQL \u62a5\u9519 Too many connections<\/h4>\n<p>\u539f\u56e0&#xff1a;\u9a71\u52a8\u5728 ResultSet \u5173\u95ed\u524d\u4e0d\u91ca\u653e\u5e95\u5c42 socket\u3002\u7a0b\u5e8f\u8dd1\u5b8c\u867d\u7136\u8fdb\u7a0b\u9000\u51fa&#xff0c;\u4f46\u771f\u5b9e\u670d\u52a1\u7aef\u7684\u8fde\u63a5\u6570\u4f1a\u7d2f\u79ef\u3002<\/p>\n<p>\u89e3\u51b3&#xff1a;\u6bcf\u4e2a Statement \u2192 ResultSet \u94fe\u7528\u5b8c\u7acb\u523b close&#xff0c;\u987a\u5e8f rs.close() \u2192 stmt.close()\u3002\u8fd9\u662f\u6570\u636e\u5e93\u7f16\u7a0b\u7684\u57fa\u672c\u7eaa\u5f8b\u3002<\/p>\n<hr \/>\n<h3>\u4e5d\u3001\u524d 8 \u8bfe\u5173\u952e API \u4e32\u70e7&#xff08;\u7efc\u5408\u901f\u67e5&#xff09;<\/h3>\n<p>\u672c\u8bfe\u628a\u524d 8 \u8bfe\u6570\u636e\u5e93\u77e5\u8bc6\u5168\u90e8\u4e32\u8d77\u6765\u4e86&#xff0c;\u4e0b\u9762\u8fd9\u5f20\u8868\u5e2e\u4f60\u5feb\u901f\u5b9a\u4f4d&#xff1a;<\/p>\n<table>\n<tr>\u573a\u666f\u7528\u6cd5\u5bf9\u5e94\u8bfe\u7a0b<\/tr>\n<tbody>\n<tr>\n<td>\u53d6\u9a71\u52a8<\/td>\n<td>DriverManager.getDriver(&#034;mariadb&#034;).getOrThrow()<\/td>\n<td>\u7b2c 07 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u8fde\u63a5<\/td>\n<td>driver.open(&#034;mariadb:\/\/host:port&#034;, [&#8230;]).connect()<\/td>\n<td>\u7b2c 07 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u6267\u884c DDL<\/td>\n<td>conn.prepareStatement(&#034;CREATE TABLE &#8230;&#034;).update()<\/td>\n<td>\u7b2c 08 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u67e5\u8be2<\/td>\n<td>conn.prepareStatement(sql).query() \u2192 while (rs.next()) { rs.get&lt;T&gt;(n) }<\/td>\n<td>\u7b2c 09 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u63d2\u5165<\/td>\n<td>conn.prepareStatement(&#034;INSERT &#8230;&#034;).update().lastInsertId<\/td>\n<td>\u7b2c 10 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u66f4\u65b0 \/ \u5220\u9664<\/td>\n<td>conn.prepareStatement(&#034;UPDATE &#8230;&#034;).update().rowCount<\/td>\n<td>\u7b2c 11 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u9884\u7f16\u8bd1&#xff08;\u5168\u8bfe\u8d2f\u7a7f&#xff09;<\/td>\n<td>SQL \u91cc\u5199 ?&#xff0c;\u6267\u884c\u524d stmt.set(n, value)<\/td>\n<td>\u7b2c 12 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u4e8b\u52a1<\/td>\n<td>let tx &#061; conn.createTransaction(); tx.begin() \u2192 try\/commit &#043; catch\/rollback<\/td>\n<td>\u7b2c 13 \u8bfe<\/td>\n<\/tr>\n<tr>\n<td>\u52a8\u6001\u96c6\u5408<\/td>\n<td>ArrayList&lt;T&gt;() &#043; .add(x) &#043; .toArray()<\/td>\n<td>\u7b2c 08 \u8bfe&#xff08;\u7b2c\u4e00\u7bc7&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Option \u89e3\u5305<\/td>\n<td>.isSome() \/ .isNone() &#043; .getOrThrow()<\/td>\n<td>\u7b2c 09 \u8bfe<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u5341\u3001FAQ<\/h3>\n<h4>Q1&#xff1a;Service \u5c42\u548c DAO \u5c42\u7684\u8fb9\u754c\u5728\u54ea&#xff1f;\u4e3a\u4ec0\u4e48\u4e0d\u628a\u8de8\u8868\u903b\u8f91\u4e5f\u5199\u5728 DAO \u91cc&#xff1f;<\/h4>\n<p>DAO \u7684\u8bbe\u8ba1\u54f2\u5b66\u662f**\u201c\u4e00\u5f20\u8868 &#061; \u4e00\u4e2a DAO\u201d**\u3002\u8de8\u4e24\u5f20\u8868\u3001\u9700\u8981\u4e8b\u52a1\u7684\u64cd\u4f5c&#xff0c;\u653e\u5728 DAO \u91cc\u4f1a\u5bfc\u81f4\u4e00\u4e2a DAO \u4f9d\u8d56\u53e6\u4e00\u4e2a DAO&#xff08;UserDao \u91cc\u8981\u8c03 TodoDao.deleteByUserId&#xff09;&#xff0c;\u804c\u8d23\u6df7\u4e71\u3002Service \u5c42\u5c31\u662f DAO \u4e4b\u4e0a\u7684&#034;\u7f16\u6392\u5c42&#034;\u2014\u2014\u5b83\u77e5\u9053\u6709\u54ea\u4e9b DAO\u3001\u8be5\u6309\u4ec0\u4e48\u987a\u5e8f\u8c03\u7528\u3001\u54ea\u91cc\u9700\u8981\u4e8b\u52a1\u3001\u54ea\u91cc\u9700\u8981\u5f02\u5e38\u515c\u5e95\u3002<\/p>\n<p>\u4e00\u4e2a\u7b80\u5355\u5224\u65ad\u6807\u51c6&#xff1a;\u65b9\u6cd5\u91cc\u53ea\u51fa\u73b0 SELECT \/ INSERT \/ UPDATE \/ DELETE \u5355\u8868\u64cd\u4f5c \u2192 DAO&#xff1b;\u65b9\u6cd5\u91cc\u51fa\u73b0\u591a\u4e2a DAO \u8c03\u7528&#xff0c;\u6216\u9700\u8981\u4e8b\u52a1 \u2192 Service\u3002<\/p>\n<h4>Q2&#xff1a;\u548c\u7b2c 29 \u8bfe\u6587\u4ef6\u7248 Todo \u5bf9\u7167\u4e00\u4e0b&#xff1f;<\/h4>\n<table>\n<tr>\u7ef4\u5ea6\u7b2c 29 \u8bfe\u6587\u4ef6\u7248\u7b2c 15 \u8bfe\u6570\u636e\u5e93\u7248<\/tr>\n<tbody>\n<tr>\n<td>\u5b58\u50a8\u4ecb\u8d28<\/td>\n<td>txt \u6587\u4ef6&#xff0c;\u6bcf\u884c\u4e00\u6761<\/td>\n<td>MySQL \u4e24\u5f20\u8868<\/td>\n<\/tr>\n<tr>\n<td>\u8bfb\u53d6\u65b9\u5f0f<\/td>\n<td>\u6574\u6587\u4ef6\u8bfb\u5165\u5185\u5b58 &#043; split<\/td>\n<td>SQL \u67e5\u8be2 &#043; ResultSet \u904d\u5386<\/td>\n<\/tr>\n<tr>\n<td>\u5199\u5165\u65b9\u5f0f<\/td>\n<td>file.write(content) \u8986\u76d6\u5199<\/td>\n<td>stmt.update() \u589e\/\u6539\/\u5220<\/td>\n<\/tr>\n<tr>\n<td>\u591a\u7528\u6237\u652f\u6301<\/td>\n<td>\u4e0d\u652f\u6301&#xff08;\u5168\u5806\u4e00\u4e2a\u6587\u4ef6&#xff09;<\/td>\n<td>\u5929\u7136\u652f\u6301&#xff08;user \u8868\u5206\u533a&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5206\u5c42<\/td>\n<td>\u5168\u5806 main<\/td>\n<td>Model &#043; DAO &#043; Service \u4e09\u5c42<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u53d1\u5b89\u5168<\/td>\n<td>\u8fdb\u7a0b\u72ec\u5360&#xff08;\u4e0d\u4f1a\u88ab\u4e24\u4e2a\u8fdb\u7a0b\u540c\u65f6\u6539&#xff09;<\/td>\n<td>\u9760\u4e8b\u52a1\u9501 &#043; \u8fde\u63a5\u6c60&#xff08;\u771f\u5b9e\u751f\u4ea7\u95ee\u9898&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4f60\u53ef\u4ee5\u770b\u5230&#xff1a;Model\u3001DAO\u3001Service \u4e09\u5c42\u5728\u4e24\u4e2a\u7248\u672c\u91cc\u4e00\u6a21\u4e00\u6837&#xff0c;\u53ea\u6709 DAO \u91cc\u7684&#034;\u600e\u4e48\u5b58\/\u600e\u4e48\u53d6&#034;\u53d8\u4e86\u3002\u8fd9\u5c31\u662f\u672c\u8bfe\u60f3\u4f20\u8fbe\u7684\u2014\u2014\u4e1a\u52a1\u903b\u8f91\u548c\u5b58\u50a8\u6280\u672f\u89e3\u8026\u3002<\/p>\n<h4>Q3&#xff1a;\u4e3a\u4ec0\u4e48\u4e0d\u7528 ConnectionPool&#xff1f;<\/h4>\n<p>\u6570\u636e\u5e93\u8fde\u63a5\u5efa\u7acb\u4e00\u6b21\u6210\u672c\u5f88\u9ad8&#xff08;TCP \u63e1\u624b &#043; \u8ba4\u8bc1 &#043; \u9ed8\u8ba4 schema \u8bbe\u7f6e&#xff09;\u3002\u771f\u5b9e\u670d\u52a1\u5668\u5e94\u8be5\u7528\u8fde\u63a5\u6c60&#xff08;\u5e94\u7528\u542f\u52a8\u65f6\u5148\u5efa 10 \u6761\u653e\u7740&#xff0c;\u7528\u7684\u65f6\u5019\u62ff\u4e00\u6761&#xff0c;\u7528\u5b8c\u8fd8\u56de\u53bb\u800c\u4e0d\u662f\u5173\u6389&#xff09;\u3002\u4f46\u672c\u8bfe\u548c mariadb-driver 1.2.0 \u90fd\u6ca1\u5185\u7f6e\u8fde\u63a5\u6c60\u2014\u2014\u6211\u4eec\u53ea\u505a\u4e00\u6b21\u8fde\u63a5\u3001\u7528\u5b8c\u5173\u6389\u7684\u6700\u7b80\u573a\u666f\u3002\u8fde\u63a5\u6c60\u662f&#034;\u751f\u4ea7\u7ea7\u4f18\u5316&#034;&#xff0c;\u521d\u5b66\u8005\u9636\u6bb5\u5148\u628a&#034;\u5355\u8fde\u63a5\u80fd\u8dd1\u901a&#034;\u5403\u900f\u518d\u8bf4\u3002<\/p>\n<h4>Q4&#xff1a;\u5982\u679c\u5c06\u6765\u60f3\u6362 SQLite&#xff1f;<\/h4>\n<p>\u6539\u4e00\u884c URL&#xff1a;&#034;sqlite:\/\/\/path\/to\/db.sqlite&#034;&#xff08;\u524d\u63d0\u662f\u6362\u7528 SQLite \u9a71\u52a8&#xff09;\u3002Service \u5c42\u548c DAO \u5c42\u4e00\u884c\u90fd\u4e0d\u7528\u6539\u2014\u2014\u56e0\u4e3a\u6211\u4eec\u7528\u7684\u90fd\u662f\u6807\u51c6 SQL &#043; std.database.sql \u6807\u51c6\u63a5\u53e3&#xff0c;\u4e0d\u4f9d\u8d56 mariadb \u7684\u7279\u5b9a\u6269\u5c55\u3002\u8fd9\u5c31\u662f&#034;\u5206\u5c42\u89e3\u8026&#034;\u7684\u597d\u5904\u3002<\/p>\n<hr \/>\n<p>\u4e0b\u4e00\u8bfe\u9884\u544a&#xff1a;\u7b2c 16 \u8bfe \u53cd\u5c04 \u2014\u2014 \u6807\u51c6\u5e93 std.reflect \u80fd\u8ba9\u7a0b\u5e8f\u5728\u8fd0\u884c\u65f6&#034;\u770b\u89c1&#034;\u81ea\u5df1&#xff1a;\u7c7b\u6709\u54ea\u4e9b\u5b57\u6bb5&#xff1f;\u65b9\u6cd5\u7b7e\u540d\u662f\u4ec0\u4e48&#xff1f;\u5b57\u6bb5\u53eb\u4ec0\u4e48\u540d\u5b57&#xff1f;\u53cd\u5c04\u662f ORM\u3001\u5e8f\u5217\u5316\u6846\u67b6\u3001\u4f9d\u8d56\u6ce8\u5165\u7684\u5e95\u5c42\u5de5\u5177&#xff0c;\u4e5f\u662f\u4ed3\u9889\u7c7b\u578b\u7cfb\u7edf\u7684&#034;\u540e\u95e8&#034;\u3002<\/p>\n<p>\u7cfb\u5217\u8bf4\u660e&#xff1a;\u672c\u7cfb\u5217\u57fa\u4e8e Windows \u5e73\u53f0 &#043; CIDE &#043; \u4ed3\u9889 SDK&#xff08;1.2.0&#xff09;\u7f16\u5199\u3002\u672c\u6587\u5168\u90e8\u4ee3\u7801\u3001\u8fd0\u884c\u8f93\u51fa\u4e0e\u62a5\u9519\u6587\u6848\u5747\u5df2\u5728 SDK 1.2.0 &#043; MySQL \u73af\u5883\u4e0b\u9010\u5757\u7f16\u8bd1\u8fd0\u884c\u3001\u9010\u5b57\u5b9e\u6d4b&#xff1b;\u5982\u9047 SDK \u7248\u672c\u5dee\u5f02\u5bfc\u81f4\u7684\u7ec6\u8282\u51fa\u5165&#xff0c;\u4ee5\u4f60\u672c\u5730\u7248\u672c\u4e3a\u51c6&#xff0c;\u6b22\u8fce\u8bc4\u8bba\u533a\u4ea4\u6d41\u3002<\/p>\n<hr \/>\n<h3>&#x1f4ac; \u9047\u5230\u95ee\u9898&#xff1f;\u626b\u7801\u8054\u7cfb\u4f5c\u8005<\/h3>\n<p>\u8ddf\u7740\u8bfe\u7a0b\u7ec3\u4e60\u65f6&#xff0c;\u5982\u679c\u5728 SDK \u5b89\u88c5\u3001\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u3001\u7f16\u8bd1\u62a5\u9519\u6216\u8c03\u8bd5\u4e0a\u5361\u4f4f&#xff0c;\u6b22\u8fce\u626b\u7801\u52a0\u4f5c\u8005\u4f01\u4e1a\u5fae\u4fe1\u76f4\u63a5\u54a8\u8be2&#xff08;\u8bf7\u5907\u6ce8&#034;\u4ed3\u9889\u8bfe\u7a0b&#034;&#xff09;&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025231620-6ade8dc494a94.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u79bb\u7ebf\u73af\u5883\u4e0b\u56fe\u7247\u53ef\u80fd\u52a0\u8f7d\u4e0d\u51fa\u6765&#xff0c;\u4e5f\u53ef\u4ee5\u5728 CIDE \u83dc\u5355 Help \u25b8 \u8054\u7cfb\u4f5c\u8005 \/ Contact \u4e2d\u67e5\u770b\u540c\u4e00\u5f20\u4e8c\u7ef4\u7801&#xff08;\u5e94\u7528\u5185\u7f6e\u515c\u5e95\u56fe&#xff0c;\u65e0\u9700\u8054\u7f51&#xff09;\u3002<\/p>\n<hr \/>\n<h3>&#x1f4e5; \u5de5\u5177\u4e0b\u8f7d<\/h3>\n<p>\u672c\u7cfb\u5217\u5168\u7a0b\u4f7f\u7528\u7684\u4ed3\u9889 IDE \u2014\u2014 CIDE&#xff08;\u514d\u8d39\u5f00\u6e90\u3001\u793e\u533a\u7248&#xff09;&#xff1a;<\/p>\n<ul>\n<li>GitCode \u4ed3\u5e93 \/ \u5b89\u88c5\u5305\u4e0b\u8f7d&#xff1a;https:\/\/gitcode.com\/wp_upala\/cide<\/li>\n<li>\u6253\u5f00\u9875\u9762\u540e\u8fdb\u5165 \u53d1\u884c\u7248&#xff08;Releases&#xff09;&#xff0c;\u4e24\u79cd\u5305\u4efb\u9009\u5176\u4e00&#xff1a;\n<ul>\n<li>\u5b89\u88c5\u7248&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Setup.exe&#xff0c;\u53cc\u51fb\u5b89\u88c5&#xff0c;\u9002\u5408\u65e5\u5e38\u957f\u671f\u4f7f\u7528&#xff1b;<\/li>\n<li>\u514d\u5b89\u88c5\u7248&#xff08;Portable&#xff09;&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Portable.zip&#xff0c;\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55\u5373\u7528&#xff0c;\u4e0d\u5199\u6ce8\u518c\u8868\u3001\u4e0d\u7559\u5b89\u88c5\u75d5\u8ff9&#xff0c;\u62f7\u5230 U \u76d8\u4e5f\u80fd\u5728\u522b\u7684\u7535\u8111\u76f4\u63a5\u8fd0\u884c&#xff08;\u5305\u5185\u9644\u300a\u4f7f\u7528\u8bf4\u660e.txt\u300b&#xff09;\u3002\u9002\u5408\u5148\u8bd5\u7528\u3001\u6216\u5728\u53d7\u9650\u7535\u8111\u4e0a\u5b66\u4e60\u672c\u7cfb\u5217\u8bfe\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4ed3\u9889 SDK \u8bf7\u524d\u5f80\u4ed3\u9889\u7f16\u7a0b\u8bed\u8a00\u5b98\u7f51\u4e0b\u8f7d&#xff1a;https:\/\/cangjie-lang.cn<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011\u7efc\u5408\u5b9e\u6218&#xff1a;\u628a Todo \u6e05\u5355\u642c\u4e0a\u6570\u636e\u5e93 \u5bfc\u822a&#xff1a;\u4e0a\u4e00\u8bfe \u7b2c 14 \u8bfe \u624b\u5199 DAO \u6570\u636e\u8bbf\u95ee\u5c42 \u2192 \u672c\u8bfe \u2192 \u4e0b\u4e00\u8bfe \u7b2c 16 \u8bfe \u53cd\u5c04 \u672c\u8bfe\u5185\u5bb9\u91cf&#xff1a;\u6b63\u6587\u7ea6 380 \u884c&#xff0c;\u5168\u7bc7\u7ea6 580 \u884c&#xff08;\u542b\u5bfc\u822a \/ FAQ \/ \u9884\u544a \/ \u4e8c\u7ef4\u7801\u9aa8\u67b6&#xff09;\u3002\u5355\u8bfe\u53ea\u805a\u7126 1 \u4e2a\u77e5\u8bc6\u70b9&#xff1a;\u628a\u524d 8 \u8bfe\u8bb2\u8fc7\u7684 SQL \u80fd\u529b&#xff08;\u5efa\u8868\u3001CRUD\u3001\u9884\u7f16\u8bd1\u3001\u4e8b\u52a1\u3001<\/p>\n","protected":false},"author":2,"featured_media":118086,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[70,190,227,100],"topic":[],"class_list":["post-118087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-ide","tag-190","tag-227","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/118087.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011\u7efc\u5408\u5b9e\u6218&#xff1a;\u628a Todo \u6e05\u5355\u642c\u4e0a\u6570\u636e\u5e93 \u5bfc\u822a&#xff1a;\u4e0a\u4e00\u8bfe \u7b2c 14 \u8bfe \u624b\u5199 DAO \u6570\u636e\u8bbf\u95ee\u5c42 \u2192 \u672c\u8bfe \u2192 \u4e0b\u4e00\u8bfe \u7b2c 16 \u8bfe \u53cd\u5c04 \u672c\u8bfe\u5185\u5bb9\u91cf&#xff1a;\u6b63\u6587\u7ea6 380 \u884c&#xff0c;\u5168\u7bc7\u7ea6 580 \u884c&#xff08;\u542b\u5bfc\u822a \/ FAQ \/ \u9884\u544a \/ \u4e8c\u7ef4\u7801\u9aa8\u67b6&#xff09;\u3002\u5355\u8bfe\u53ea\u805a\u7126 1 \u4e2a\u77e5\u8bc6\u70b9&#xff1a;\u628a\u524d 8 \u8bfe\u8bb2\u8fc7\u7684 SQL \u80fd\u529b&#xff08;\u5efa\u8868\u3001CRUD\u3001\u9884\u7f16\u8bd1\u3001\u4e8b\u52a1\u3001\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/118087.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-25T23:16:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025231620-6ade8dc494a94.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118087.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/118087.html\",\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-25T23:16:22+00:00\",\"dateModified\":\"2026-10-25T23:16:22+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/118087.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/118087.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/118087.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/118087.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011\u7efc\u5408\u5b9e\u6218&#xff1a;\u628a Todo \u6e05\u5355\u642c\u4e0a\u6570\u636e\u5e93 \u5bfc\u822a&#xff1a;\u4e0a\u4e00\u8bfe \u7b2c 14 \u8bfe \u624b\u5199 DAO \u6570\u636e\u8bbf\u95ee\u5c42 \u2192 \u672c\u8bfe \u2192 \u4e0b\u4e00\u8bfe \u7b2c 16 \u8bfe \u53cd\u5c04 \u672c\u8bfe\u5185\u5bb9\u91cf&#xff1a;\u6b63\u6587\u7ea6 380 \u884c&#xff0c;\u5168\u7bc7\u7ea6 580 \u884c&#xff08;\u542b\u5bfc\u822a \/ FAQ \/ \u9884\u544a \/ \u4e8c\u7ef4\u7801\u9aa8\u67b6&#xff09;\u3002\u5355\u8bfe\u53ea\u805a\u7126 1 \u4e2a\u77e5\u8bc6\u70b9&#xff1a;\u628a\u524d 8 \u8bfe\u8bb2\u8fc7\u7684 SQL \u80fd\u529b&#xff08;\u5efa\u8868\u3001CRUD\u3001\u9884\u7f16\u8bd1\u3001\u4e8b\u52a1\u3001","og_url":"https:\/\/www.wsisp.com\/helps\/118087.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-25T23:16:22+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261025231620-6ade8dc494a94.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/118087.html","url":"https:\/\/www.wsisp.com\/helps\/118087.html","name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-25T23:16:22+00:00","dateModified":"2026-10-25T23:16:22+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/118087.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/118087.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/118087.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c\u4e8c\u7bc7 \u7b2c 15 \u8bfe\u3011"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=118087"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/118087\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/118086"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=118087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=118087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=118087"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=118087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}