{"id":6816,"date":"2024-11-14T13:47:20","date_gmt":"2024-11-14T05:47:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6816\/"},"modified":"2024-11-14T13:47:20","modified_gmt":"2024-11-14T05:47:20","slug":"mysql%e9%a2%84%e7%bc%96%e8%af%91%ef%bc%9a%e5%ae%a2%e6%88%b7%e7%ab%af%e5%92%8c%e6%9c%8d%e5%8a%a1%e7%ab%af%ef%bc%8c%e4%bd%a0%e7%9c%9f%e7%9a%84%e4%ba%86%e8%a7%a3%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6816\/","title":{"rendered":"MySQL\u9884\u7f16\u8bd1\uff1a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\uff0c\u4f60\u771f\u7684\u4e86\u89e3\u5417\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/172994690124728.jpg\" class=\"aligncenter\" title=\"MySQL\u9884\u7f16\u8bd1\uff1a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\uff0c\u4f60\u771f\u7684\u4e86\u89e3\u5417\uff1f\u63d2\u56fe\" alt=\"MySQL\u9884\u7f16\u8bd1\uff1a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\uff0c\u4f60\u771f\u7684\u4e86\u89e3\u5417\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7406\u89e3\u9884\u7f16\u8bd1\u7684\u5965\u79d8\uff1a\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u7684\u4e0d\u540c\u73a9\u6cd5<\/strong><\/p>\n<p>\u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\uff0c\u9884\u7f16\u8bd1\u662f\u4e00\u4e2a\u4e0d\u53ef\u5ffd\u89c6\u7684\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u663e\u7740\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002\u4f46\u5bf9\u4e8emysql\u7684\u9884\u7f16\u8bd1\uff0c\u7f51\u4e0a\u6d41\u4f20\u7740\u8bb8\u591a\u8bf4\u6cd5\uff0c\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\u3002\u672c\u6587\u5c06\u5206\u522b\u4ecb\u7ecdmysql\u7684\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u548c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\uff0c\u5e76\u89e3\u7b54\u5982\u4f55\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u3002 <\/p>\n<p><strong>\u9ed8\u8ba4\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u9700\u8981\u660e\u786e\u7684\u662f\uff0cmysql\u9ed8\u8ba4\u91c7\u7528\u7684\u662f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u3002\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u662f\u6307\u5ba2\u6237\u7aef\u5c06\u5305\u542b\u53c2\u6570\u7684\u8f6c\u6362\u6210\u4e00\u4e2a\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u7136\u540e\u628a\u9884\u7f16\u8bd1\u8bed\u53e5\u548c\u53c2\u6570\u4e00\u5e76\u53d1\u9001\u7ed9\u6570\u636e\u5e93\u3002\u6570\u636e\u5e93\u89e3\u6790\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u6839\u636e\u53c2\u6570\u751f\u6210\u6267\u884c\u8ba1\u5212\uff0c\u5e76\u6267\u884c\u67e5\u8be2\u3002 <\/p>\n<p><strong>\u670d\u52a1\u7aef\u9884\u7f16\u8bd1<\/strong><\/p>\n<p>\u4e0e\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u4e0d\u540c\uff0c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u662f\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u7684\u3002\u6570\u636e\u5e93\u670d\u52a1\u5668\u89e3\u6790\u5305\u542b\u53c2\u6570\u7684sql\u8bed\u53e5\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u6267\u884c\u8ba1\u5212\u3002\u5f53\u5ba2\u6237\u7aef\u4f7f\u7528\u76f8\u540c\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u518d\u6b21\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5668\u53ef\u4ee5\u76f4\u63a5\u590d\u7528\u4e4b\u524d\u751f\u6210\u7684\u6267\u884c\u8ba1\u5212\uff0c\u65e0\u9700\u91cd\u65b0\u89e3\u6790sql\u8bed\u53e5\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002 <\/p>\n<p><strong>\u5f00\u542f\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1<\/strong><\/p>\n<p>\u8981\u540c\u65f6\u5f00\u542f\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\uff0c\u9700\u8981\u5728\u94fe\u63a5\u4e2d\u52a0\u4e0auseserverprepstmts=true\u548ccacheprepstmts=true\u4e24\u4e2a\u53c2\u6570\u3002 <\/p>\n<p><strong>\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1<\/strong><\/p>\n<p>\u8981\u53ea\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\uff0c\u53ef\u4ee5\u5c06useserverprepstmts\u53c2\u6570\u8bbe\u7f6e\u4e3afalse\u3002\u5177\u4f53\u505a\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>\/\/ \u53ea\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\nConnection con = DriverManager.getConnection(\"jdbc:mysql:\/\/localhost:3306\/test\", \"root\", \"password\");\ncon.setClientInfo(\"useServerPrepStmts\", \"false\");<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u603b\u800c\u8a00\u4e4b\uff0cmysql\u7684\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u548c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u5404\u6709\u7279\u70b9\u3002\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u548c\u9884\u7f16\u8bd1\u7f13\u5b58\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u800c\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u5219\u53ef\u4ee5\u6839\u636e\u9700\u8981\u63a7\u5236\u9884\u7f16\u8bd1\u7684\u884c\u4e3a\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL\u9884\u7f16\u8bd1\uff1a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\uff0c\u4f60\u771f\u7684\u4e86\u89e3\u5417\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7406\u89e3\u9884\u7f16\u8bd1\u7684\u5965\u79d8\uff1a\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u7684\u4e0d\u540c\u73a9\u6cd5 \u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\uff0c\u9884\u7f16\u8bd1\u662f\u4e00\u4e2a\u4e0d\u53ef\u5ffd\u89c6\u7684\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u663e\u7740\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002\u4f46\u5bf9\u4e8emysql\u7684\u9884\u7f16\u8bd1\uff0c\u7f51\u4e0a\u6d41\u4f20\u7740\u8bb8\u591a\u8bf4\u6cd5\uff0c\u8ba9\u4eba\u6478\u4e0d\u7740\u5934\u8111\u3002\u672c\u6587\u5c06\u5206\u522b\u4ecb\u7ecdmysql\u7684\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u548c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\uff0c\u5e76\u89e3\u7b54\u5982\u4f55\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u3002 \u9ed8\u8ba4\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1 \u9996\u5148\uff0c\u9700\u8981\u660e\u786e\u7684\u662f\uff0cmysql\u9ed8\u8ba4\u91c7\u7528\u7684\u662f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u3002\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u662f\u6307\u5ba2\u6237\u7aef\u5c06\u5305\u542b\u53c2\u6570\u7684\u8f6c\u6362\u6210\u4e00\u4e2a\u9884\u7f16\u8bd1\u8bed\u53e5\uff0c\u7136\u540e\u628a\u9884\u7f16\u8bd1\u8bed\u53e5\u548c\u53c2\u6570\u4e00\u5e76\u53d1\u9001\u7ed9\u6570\u636e\u5e93\u3002\u6570\u636e\u5e93\u89e3\u6790\u9884\u7f16\u8bd1\u8bed\u53e5\u540e\uff0c\u6839\u636e\u53c2\u6570\u751f\u6210\u6267\u884c\u8ba1\u5212\uff0c\u5e76\u6267\u884c\u67e5\u8be2\u3002 \u670d\u52a1\u7aef\u9884\u7f16\u8bd1 \u4e0e\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u4e0d\u540c\uff0c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u662f\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\u8fdb\u884c\u7684\u3002\u6570\u636e\u5e93\u670d\u52a1\u5668\u89e3\u6790\u5305\u542b\u53c2\u6570\u7684sql\u8bed\u53e5\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u6267\u884c\u8ba1\u5212\u3002\u5f53\u5ba2\u6237\u7aef\u4f7f\u7528\u76f8\u540c\u7684\u9884\u7f16\u8bd1\u8bed\u53e5\u518d\u6b21\u6267\u884c\u67e5\u8be2\u65f6\uff0c\u6570\u636e\u5e93\u670d\u52a1\u5668\u53ef\u4ee5\u76f4\u63a5\u590d\u7528\u4e4b\u524d\u751f\u6210\u7684\u6267\u884c\u8ba1\u5212\uff0c\u65e0\u9700\u91cd\u65b0\u89e3\u6790sql\u8bed\u53e5\uff0c\u4ece\u800c\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002 \u5f00\u542f\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1 \u8981\u540c\u65f6\u5f00\u542f\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\uff0c\u9700\u8981\u5728\u94fe\u63a5\u4e2d\u52a0\u4e0auseserverprepstmts=true\u548ccacheprepstmts=true\u4e24\u4e2a\u53c2\u6570\u3002 \u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1 \u8981\u53ea\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u800c\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\uff0c\u53ef\u4ee5\u5c06useserverprepstmts\u53c2\u6570\u8bbe\u7f6e\u4e3afalse\u3002\u5177\u4f53\u505a\u6cd5\u5982\u4e0b\uff1a \/\/ \u53ea\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1 Connection con = DriverManager.getConnection(&#8220;jdbc:mysql:\/\/localhost:3306\/test&#8221;, &#8220;root&#8221;, &#8220;password&#8221;); con.setClientInfo(&#8220;useServerPrepStmts&#8221;, &#8220;false&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u603b\u800c\u8a00\u4e4b\uff0cmysql\u7684\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u548c\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u5404\u6709\u7279\u70b9\u3002\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u548c\u9884\u7f16\u8bd1\u7f13\u5b58\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u800c\u5f00\u542f\u5ba2\u6237\u7aef\u9884\u7f16\u8bd1\u4e0d\u5f00\u542f\u670d\u52a1\u7aef\u9884\u7f16\u8bd1\u5219\u53ef\u4ee5\u6839\u636e\u9700\u8981\u63a7\u5236\u9884\u7f16\u8bd1\u7684\u884c\u4e3a\u3002 \u4ee5\u4e0a\u5c31\u662fMySQL\u9884\u7f16\u8bd1\uff1a\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\uff0c\u4f60\u771f\u7684\u4e86\u89e3\u5417\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6816","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6816"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6816\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}