{"id":5722,"date":"2024-08-01T22:46:59","date_gmt":"2024-08-01T14:46:59","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=5722"},"modified":"2024-08-01T22:46:59","modified_gmt":"2024-08-01T14:46:59","slug":"13-%e7%a7%92%e6%8f%92%e5%85%a5-30-%e4%b8%87%e6%9d%a1%e6%95%b0%e6%8d%ae%ef%bc%8c%e8%bf%99%e6%89%8d%e6%98%af%e6%89%b9%e9%87%8f%e6%8f%92%e5%85%a5%e6%ad%a3%e7%a1%ae%e7%9a%84%e5%a7%bf%e5%8a%bf%ef%bc%81","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/13-%e7%a7%92%e6%8f%92%e5%85%a5-30-%e4%b8%87%e6%9d%a1%e6%95%b0%e6%8d%ae%ef%bc%8c%e8%bf%99%e6%89%8d%e6%98%af%e6%89%b9%e9%87%8f%e6%8f%92%e5%85%a5%e6%ad%a3%e7%a1%ae%e7%9a%84%e5%a7%bf%e5%8a%bf%ef%bc%81\/","title":{"rendered":"13 \u79d2\u63d2\u5165 30 \u4e07\u6761\u6570\u636e\uff0c\u8fd9\u624d\u662f\u6279\u91cf\u63d2\u5165\u6b63\u786e\u7684\u59ff\u52bf\uff01"},"content":{"rendered":"<div class='wxsyncmain'>\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"padding-right: 10px;padding-left: 10px;text-align: left;line-height: 1.6;letter-spacing: 0.034em;color: rgb(63, 63, 63);font-size: 16px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;\" data-mpa-powered-by=\"yiban.io\">\n<p style=\"text-align: left;line-height: 2em;margin-bottom: 5px;margin-left: 8px;margin-right: 8px;\"><span style=\"color: rgb(0, 82, 255);letter-spacing: 0.544px;font-size: 15px;\"><span style=\"font-size: 16px;color: rgb(53, 53, 53);letter-spacing: 0.8px;word-spacing: 0.8px;\"><\/span><\/span><span style=\"color: rgb(74, 74, 74);letter-spacing: 0.034em;\">\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0\u901a\u8fc7MyBatis\u3001JDBC\u7b49\u505a\u5927\u6570\u636e\u91cf\u6570\u636e\u63d2\u5165\u7684\u6848\u4f8b\u548c\u7ed3\u679c\u3002<\/span><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"font-weight: bold;color: black;font-size: 22px;text-align: center;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222240878.png');background-position: center center;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;background-size: 50px;margin-top: 1em;margin-bottom: 10px;\"><span style=\"display: inline-block;height: 38px;line-height: 42px;color: rgb(72, 179, 120);background-position: left center;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;background-size: 63px;margin-top: 38px;font-size: 18px;margin-bottom: 10px;\">30\u4e07\u6761\u6570\u636e\u63d2\u5165\u63d2\u5165\u6570\u636e\u5e93\u9a8c\u8bc1<\/span><\/h2>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5b9e\u4f53\u7c7b\u3001mapper\u548c\u914d\u7f6e\u6587\u4ef6\u5b9a\u4e49<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\"><\/section>\n<\/li>\n<ul style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: square;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">User\u5b9e\u4f53<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">mapper\u63a5\u53e3<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">mapper.xml\u6587\u4ef6<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">jdbc.properties<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">sqlMapConfig.xml<\/section>\n<\/li>\n<\/ul>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4e0d\u5206\u6279\u6b21\u76f4\u63a5\u68ad\u54c8<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5faa\u73af\u9010\u6761\u63d2\u5165<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">MyBatis\u5b9e\u73b0\u63d2\u516530\u4e07\u6761\u6570\u636e<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">JDBC\u5b9e\u73b0\u63d2\u516530\u4e07\u6761\u6570\u636e<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u603b\u7ed3<\/p>\n<\/section>\n<\/li>\n<\/ul>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u9a8c\u8bc1\u7684\u6570\u636e\u5e93\u8868\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">CREATETABLE`t_user`(`id`int(11)NOTNULLAUTO_INCREMENTCOMMENT<span style=\"color: #a6e22e;line-height: 26px;\">'\u7528\u6237id'<\/span>,`username`varchar(64)DEFAULTNULLCOMMENT<span style=\"color: #a6e22e;line-height: 26px;\">'\u7528\u6237\u540d\u79f0'<\/span>,`age`int(4)DEFAULTNULLCOMMENT<span style=\"color: #a6e22e;line-height: 26px;\">'\u5e74\u9f84'<\/span>,PRIMARYKEY(`id`))ENGINE=InnoDBDEFAULTCHARSET=utf8COMMENT=<span style=\"color: #a6e22e;line-height: 26px;\">'\u7528\u6237\u4fe1\u606f\u8868'<\/span>;<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u8bdd\u4e0d\u591a\u8bf4\uff0c\u5f00\u6574\uff01<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">\u5b9e\u4f53\u7c7b\u3001mapper\u548c\u914d\u7f6e\u6587\u4ef6\u5b9a\u4e49<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">User\u5b9e\u4f53<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">\/***&lt;p&gt;\u7528\u6237\u5b9e\u4f53&lt;\/p&gt;**@Authorzjq*\/@DatapublicclassUser{privateintid;privateStringusername;privateintage;}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">mapper\u63a5\u53e3<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">publicinterfaceUserMapper{\/***\u6279\u91cf\u63d2\u5165\u7528\u6237*@paramuserList*\/voidbatchInsertUser(@Param(<span style=\"color: #a6e22e;line-height: 26px;\">\"list\"<\/span>)List&lt;User&gt;userList);}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">mapper.xml\u6587\u4ef6<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">&lt;!--\u6279\u91cf\u63d2\u5165\u7528\u6237\u4fe1\u606f--&gt;&lt;insertid=<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>parameterType=<span style=\"color: #a6e22e;line-height: 26px;\">\"java.util.List\"<\/span>&gt;insertintot_user(username,age)values&lt;foreachcollection=<span style=\"color: #a6e22e;line-height: 26px;\">\"list\"<\/span>item=<span style=\"color: #a6e22e;line-height: 26px;\">\"item\"<\/span>index=<span style=\"color: #a6e22e;line-height: 26px;\">\"index\"<\/span>separator=<span style=\"color: #a6e22e;line-height: 26px;\">\",\"<\/span>&gt;(<span style=\"color: #75715e;line-height: 26px;\">#{item.username},<\/span><span style=\"color: #75715e;line-height: 26px;\">#{item.age}<\/span>)&lt;\/foreach&gt;&lt;\/insert&gt;<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">jdbc.properties<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql:\/\/localhost:3306\/<span style=\"color: #a6e22e;line-height: 26px;\">test<\/span>jdbc.username=rootjdbc.password=root<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">sqlMapConfig.xml<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">&lt;?xmlversion=<span style=\"color: #a6e22e;line-height: 26px;\">\"1.0\"<\/span>encoding=<span style=\"color: #a6e22e;line-height: 26px;\">\"UTF-8\"<\/span>?&gt;&lt;!DOCTYPEconfigurationPUBLIC<span style=\"color: #a6e22e;line-height: 26px;\">\"-\/\/mybatis.org\/\/DTDConfig3.0\/\/EN\"<\/span><span style=\"color: #a6e22e;line-height: 26px;\">\"http:\/\/mybatis.org\/dtd\/mybatis-3-config.dtd\"<\/span>&gt;&lt;configuration&gt;&lt;!--\u901a\u8fc7properties\u6807\u7b7e\u52a0\u8f7d\u5916\u90e8properties\u6587\u4ef6--&gt;&lt;propertiesresource=<span style=\"color: #a6e22e;line-height: 26px;\">\"jdbc.properties\"<\/span>&gt;&lt;\/properties&gt;&lt;!--\u81ea\u5b9a\u4e49\u522b\u540d--&gt;&lt;typeAliases&gt;&lt;typeAlias<span style=\"color: #a6e22e;line-height: 26px;\">type<\/span>=<span style=\"color: #a6e22e;line-height: 26px;\">\"com.zjq.domain.User\"<\/span><span style=\"color: #a6e22e;line-height: 26px;\">alias<\/span>=<span style=\"color: #a6e22e;line-height: 26px;\">\"user\"<\/span>&gt;&lt;\/typeAlias&gt;&lt;\/typeAliases&gt;&lt;!--\u6570\u636e\u6e90\u73af\u5883--&gt;&lt;environmentsdefault=<span style=\"color: #a6e22e;line-height: 26px;\">\"developement\"<\/span>&gt;&lt;environmentid=<span style=\"color: #a6e22e;line-height: 26px;\">\"developement\"<\/span>&gt;&lt;transactionManager<span style=\"color: #a6e22e;line-height: 26px;\">type<\/span>=<span style=\"color: #a6e22e;line-height: 26px;\">\"JDBC\"<\/span>&gt;&lt;\/transactionManager&gt;&lt;dataSource<span style=\"color: #a6e22e;line-height: 26px;\">type<\/span>=<span style=\"color: #a6e22e;line-height: 26px;\">\"POOLED\"<\/span>&gt;&lt;propertyname=<span style=\"color: #a6e22e;line-height: 26px;\">\"driver\"<\/span>value=<span style=\"color: #a6e22e;line-height: 26px;\">\"<span style=\"line-height: 26px;\">${jdbc.driver}<\/span>\"<\/span>\/&gt;&lt;propertyname=<span style=\"color: #a6e22e;line-height: 26px;\">\"url\"<\/span>value=<span style=\"color: #a6e22e;line-height: 26px;\">\"<span style=\"line-height: 26px;\">${jdbc.url}<\/span>\"<\/span>\/&gt;&lt;propertyname=<span style=\"color: #a6e22e;line-height: 26px;\">\"username\"<\/span>value=<span style=\"color: #a6e22e;line-height: 26px;\">\"<span style=\"line-height: 26px;\">${jdbc.username}<\/span>\"<\/span>\/&gt;&lt;propertyname=<span style=\"color: #a6e22e;line-height: 26px;\">\"password\"<\/span>value=<span style=\"color: #a6e22e;line-height: 26px;\">\"<span style=\"line-height: 26px;\">${jdbc.password}<\/span>\"<\/span>\/&gt;&lt;\/dataSource&gt;&lt;\/environment&gt;&lt;\/environments&gt;&lt;!--\u52a0\u8f7d\u6620\u5c04\u6587\u4ef6--&gt;&lt;mappers&gt;&lt;mapperresource=<span style=\"color: #a6e22e;line-height: 26px;\">\"com\/zjq\/mapper\/UserMapper.xml\"<\/span>&gt;&lt;\/mapper&gt;&lt;\/mappers&gt;&lt;\/configuration&gt;<\/code><\/pre>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">\u4e0d\u5206\u6279\u6b21\u76f4\u63a5\u68ad\u54c8<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">MyBatis\u76f4\u63a5\u4e00\u6b21\u6027\u6279\u91cf\u63d2\u516530\u4e07\u6761\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">@TestpublicvoidtestBatchInsertUser()throwsIOException{InputStreamresourceAsStream=Resources.getResourceAsStream(<span style=\"color: #a6e22e;line-height: 26px;\">\"sqlMapConfig.xml\"<\/span>);SqlSessionFactorysqlSessionFactory=newSqlSessionFactoryBuilder().build(resourceAsStream);SqlSessionsession=sqlSessionFactory.openSession();System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"=====\u5f00\u59cb\u63d2\u5165\u6570\u636e=====\"<\/span>);longstartTime=System.currentTimeMillis();try{List&lt;User&gt;userList=newArrayList&lt;&gt;();<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">for<\/span>(inti=1;i&lt;=300000;i++){Useruser=newUser();user.setId(i);user.setUsername(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u5171\u996e\u4e00\u676f\u65e0\"<\/span>+i);user.setAge((int)(Math.random()*100));userList.add(user);}session.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>,userList);\/\/\u6700\u540e\u63d2\u5165\u5269\u4f59\u7684\u6570\u636esession.commit();longspendTime=System.currentTimeMillis()-startTime;System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165 30\u4e07\u6761\u6570\u636e,\u8017\u65f6\uff1a\"<\/span>+spendTime+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6beb\u79d2\"<\/span>);}finally{session.close();}}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u53ef\u4ee5\u770b\u5230\u63a7\u5236\u53f0\u8f93\u51fa\uff1a<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;background: rgb(251, 249, 253);color: rgb(106, 115, 125);margin-bottom: 20px;margin-top: 20px;padding: 15px 20px;line-height: 27px;border-left-color: rgb(53, 179, 120);\">\n<p style=\"line-height: 26px;font-size: 15px;color: rgb(89, 89, 89);\">Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (27759038 &gt;yun 4194304). You can change this value on the server by setting the max_allowed_packet\u2019 variable.<\/p>\n<\/blockquote>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.37962962962962965\"  data-type=\"png\" data-w=\"1080\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.37962962962962965\"  data-type=\"png\" data-w=\"1080\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u8d85\u51fa\u6700\u5927\u6570\u636e\u5305\u9650\u5236\u4e86\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574<code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">max_allowed_packet<\/code>\u9650\u5236\u6765\u63d0\u9ad8\u53ef\u4ee5\u4f20\u8f93\u7684\u5185\u5bb9\uff0c\u4e0d\u8fc7\u7531\u4e8e30\u4e07\u6761\u6570\u636e\u8d85\u51fa\u592a\u591a\uff0c\u8fd9\u4e2a\u4e0d\u53ef\u53d6\uff0c\u68ad\u54c8\u770b\u6765\u662f\u4e0d\u884c\u4e86 \ud83d\ude05\ud83d\ude05\ud83d\ude05<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u65e2\u7136\u68ad\u54c8\u4e0d\u884c\u90a3\u6211\u4eec\u5c31\u4e00\u6761\u4e00\u6761\u5faa\u73af\u7740\u63d2\u5165\u884c\u4e0d\u884c\u5462\uff01<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">\u5faa\u73af\u9010\u6761\u63d2\u5165<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">mapper\u63a5\u53e3\u548cmapper\u6587\u4ef6\u4e2d\u65b0\u589e\u5355\u4e2a\u7528\u6237\u65b0\u589e\u7684\u5185\u5bb9\u5982\u4e0b:<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">\/***\u65b0\u589e\u5355\u4e2a\u7528\u6237*@paramuser*\/voidinsertUser(Useruser);&lt;!--\u65b0\u589e\u7528\u6237\u4fe1\u606f--&gt;&lt;insertid=<span style=\"color: #a6e22e;line-height: 26px;\">\"insertUser\"<\/span>parameterType=<span style=\"color: #a6e22e;line-height: 26px;\">\"user\"<\/span>&gt;insertintot_user(username,age)values(<span style=\"color: #75715e;line-height: 26px;\">#{username},<\/span><span style=\"color: #75715e;line-height: 26px;\">#{age}<\/span>)&lt;\/insert&gt;<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u8c03\u6574\u6267\u884c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">@TestpublicvoidtestCirculateInsertUser()throwsIOException{InputStreamresourceAsStream=Resources.getResourceAsStream(<span style=\"color: #a6e22e;line-height: 26px;\">\"sqlMapConfig.xml\"<\/span>);SqlSessionFactorysqlSessionFactory=newSqlSessionFactoryBuilder().build(resourceAsStream);SqlSessionsession=sqlSessionFactory.openSession();System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"=====\u5f00\u59cb\u63d2\u5165\u6570\u636e=====\"<\/span>);longstartTime=System.currentTimeMillis();try{<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">for<\/span>(inti=1;i&lt;=300000;i++){Useruser=newUser();user.setId(i);user.setUsername(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u5171\u996e\u4e00\u676f\u65e0\"<\/span>+i);user.setAge((int)(Math.random()*100));\/\/\u4e00\u6761\u4e00\u6761\u65b0\u589esession.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"insertUser\"<\/span>,user);session.commit();}longspendTime=System.currentTimeMillis()-startTime;System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165 30\u4e07\u6761\u6570\u636e,\u8017\u65f6\uff1a\"<\/span>+spendTime+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6beb\u79d2\"<\/span>);}finally{session.close();}}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u6267\u884c\u540e\u53ef\u4ee5\u53d1\u73b0\u78c1\u76d8IO\u5360\u6bd4\u98d9\u5347\uff0c\u4e00\u76f4\u5904\u4e8e\u9ad8\u4f4d\u3002<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"1.141263940520446\"  data-type=\"png\" data-w=\"269\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222301583.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"1.141263940520446\"  data-type=\"png\" data-w=\"269\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222301583.png\"  \/><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u7b49\u554a\u7b49\u7b49\u554a\u7b49\uff0c\u597d\u4e45\u8fd8\u6ca1\u6267\u884c\u5b8c<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.5125\"  data-type=\"gif\" data-w=\"640\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222306775.gif\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.5125\"  data-type=\"gif\" data-w=\"640\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222306775.gif\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5148\u4e0d\u7ba1\u4ed6\u4e86\u592a\u6162\u4e86\u5148\u641e\u5176\u4ed6\u7684\uff0c\u7b49\u4f1a\u518d\u6765\u770b\u770b\u7ed3\u679c\u5427\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">two thousand year later \u2026<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u63a7\u5236\u53f0\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.3425925925925926\"  data-type=\"png\" data-w=\"1080\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222328842.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.3425925925925926\"  data-type=\"png\" data-w=\"1080\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222328842.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u603b\u5171\u6267\u884c\u4e8614909367\u6beb\u79d2\uff0c\u6362\u7b97\u51fa\u6765\u662f4\u5c0f\u65f6\u516b\u5206\u949f\u3002\u592a\u6162\u4e86\u3002\u3002<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.935126582278481\"  data-type=\"png\" data-w=\"632\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222345837.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.935126582278481\"  data-type=\"png\" data-w=\"632\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222345837.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u8fd8\u662f\u4f18\u5316\u4e0b\u4e4b\u524d\u7684\u6279\u5904\u7406\u65b9\u6848\u5427\u3002<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">MyBatis\u5b9e\u73b0\u63d2\u516530\u4e07\u6761\u6570\u636e<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5148\u6e05\u7406\u8868\u6570\u636e\uff0c\u7136\u540e\u4f18\u5316\u6279\u5904\u7406\u6267\u884c\u63d2\u5165\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">--\u6e05\u7a7a\u7528\u6237\u8868TRUNCATEtablet_user;<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4ee5\u4e0b\u662f\u901a\u8fc7 MyBatis \u5b9e\u73b0 30 \u4e07\u6761\u6570\u636e\u63d2\u5165\u4ee3\u7801\u5b9e\u73b0\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">\/***\u5206\u6279\u6b21\u6279\u91cf\u63d2\u5165*@throwsIOException*\/@TestpublicvoidtestBatchInsertUser()throwsIOException{InputStreamresourceAsStream=Resources.getResourceAsStream(<span style=\"color: #a6e22e;line-height: 26px;\">\"sqlMapConfig.xml\"<\/span>);SqlSessionFactorysqlSessionFactory=newSqlSessionFactoryBuilder().build(resourceAsStream);SqlSessionsession=sqlSessionFactory.openSession();System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"=====\u5f00\u59cb\u63d2\u5165\u6570\u636e=====\"<\/span>);longstartTime=System.currentTimeMillis();intwaitTime=10;try{List&lt;User&gt;userList=newArrayList&lt;&gt;();<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">for<\/span>(inti=1;i&lt;=300000;i++){Useruser=newUser();user.setId(i);user.setUsername(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u5171\u996e\u4e00\u676f\u65e0\"<\/span>+i);user.setAge((int)(Math.random()*100));userList.add(user);<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(i%1000==0){session.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>,userList);\/\/\u6bcf1000\u6761\u6570\u636e\u63d0\u4ea4\u4e00\u6b21\u4e8b\u52a1session.commit();userList.clear();\/\/\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4Thread.sleep(waitTime*1000);}}\/\/\u6700\u540e\u63d2\u5165\u5269\u4f59\u7684\u6570\u636e<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(!CollectionUtils.isEmpty(userList)){session.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>,userList);session.commit();}longspendTime=System.currentTimeMillis()-startTime;System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165 30\u4e07\u6761\u6570\u636e,\u8017\u65f6\uff1a\"<\/span>+spendTime+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6beb\u79d2\"<\/span>);}catch(Exceptione){e.printStackTrace();}finally{session.close();}}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4f7f\u7528\u4e86 MyBatis \u7684\u6279\u5904\u7406\u64cd\u4f5c\uff0c\u5c06\u6bcf 1000 \u6761\u6570\u636e\u653e\u5728\u4e00\u4e2a\u6279\u6b21\u4e2d\u63d2\u5165\uff0c\u80fd\u591f\u8f83\u4e3a\u6709\u6548\u5730\u63d0\u9ad8\u63d2\u5165\u901f\u5ea6\u3002\u540c\u65f6\u8bf7\u6ce8\u610f\u5728\u5faa\u73af\u63d2\u5165\u65f6\u8981\u5e26\u6709\u5408\u9002\u7684\u7b49\u5f85\u65f6\u95f4\u548c\u6279\u5904\u7406\u5927\u5c0f\uff0c\u4ee5\u9632\u6b62\u51fa\u73b0\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u7b49\u95ee\u9898\u3002\u6b64\u5916\uff0c\u8fd8\u9700\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u5408\u7406\u7684\u8fde\u63a5\u6c60\u548c\u6570\u636e\u5e93\u7684\u53c2\u6570\uff0c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.6509661835748792\"  data-type=\"png\" data-w=\"828\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222355456.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.6509661835748792\"  data-type=\"png\" data-w=\"828\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222355456.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u6bcf\u63d2\u51651000\u884c\u6570\u636e\u5c31\u8fdb\u884c\u4e00\u6b21\u6279\u5904\u7406\u63d0\u4ea4\uff0c\u5e76\u7b49\u5f8510\u79d2\u949f\u3002\u8fd9\u6709\u52a9\u4e8e\u63a7\u5236\u5185\u5b58\u5360\u7528\uff0c\u5e76\u786e\u4fdd\u63d2\u5165\u64cd\u4f5c\u5e73\u7a33\u8fdb\u884c\u3002<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.2567703109327984\"  data-type=\"png\" data-w=\"997\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222407440.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.2567703109327984\"  data-type=\"png\" data-w=\"997\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222407440.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4e94\u5341\u5206\u949f\u6267\u884c\u5b8c\u6bd5\uff0c\u65f6\u95f4\u4e3b\u8981\u7528\u5728\u4e86\u7b49\u5f85\u4e0a\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5982\u679c\u4f4e\u8c37\u65f6\u671f\u6267\u884c\uff0cCPU\u548c\u78c1\u76d8\u6027\u80fd\u53c8\u8db3\u591f\u7684\u60c5\u51b5\u4e0b\uff0c\u76f4\u63a5\u6279\u5904\u7406\u4e0d\u7b49\u5f85\u6267\u884c\uff1a<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">\/***\u5206\u6279\u6b21\u6279\u91cf\u63d2\u5165*@throwsIOException*\/@TestpublicvoidtestBatchInsertUser()throwsIOException{InputStreamresourceAsStream=Resources.getResourceAsStream(<span style=\"color: #a6e22e;line-height: 26px;\">\"sqlMapConfig.xml\"<\/span>);SqlSessionFactorysqlSessionFactory=newSqlSessionFactoryBuilder().build(resourceAsStream);SqlSessionsession=sqlSessionFactory.openSession();System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"=====\u5f00\u59cb\u63d2\u5165\u6570\u636e=====\"<\/span>);longstartTime=System.currentTimeMillis();intwaitTime=10;try{List&lt;User&gt;userList=newArrayList&lt;&gt;();<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">for<\/span>(inti=1;i&lt;=300000;i++){Useruser=newUser();user.setId(i);user.setUsername(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u5171\u996e\u4e00\u676f\u65e0\"<\/span>+i);user.setAge((int)(Math.random()*100));userList.add(user);<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(i%1000==0){session.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>,userList);\/\/\u6bcf1000\u6761\u6570\u636e\u63d0\u4ea4\u4e00\u6b21\u4e8b\u52a1session.commit();userList.clear();}}\/\/\u6700\u540e\u63d2\u5165\u5269\u4f59\u7684\u6570\u636e<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(!CollectionUtils.isEmpty(userList)){session.insert(<span style=\"color: #a6e22e;line-height: 26px;\">\"batchInsertUser\"<\/span>,userList);session.commit();}longspendTime=System.currentTimeMillis()-startTime;System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165 30\u4e07\u6761\u6570\u636e,\u8017\u65f6\uff1a\"<\/span>+spendTime+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6beb\u79d2\"<\/span>);}catch(Exceptione){e.printStackTrace();}finally{session.close();}}<\/code><\/pre>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u521924\u79d2\u53ef\u4ee5\u5b8c\u6210\u6570\u636e\u63d2\u5165\u64cd\u4f5c\uff1a<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.5928677563150074\"  data-type=\"png\" data-w=\"673\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222423853.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.5928677563150074\"  data-type=\"png\" data-w=\"673\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222423853.png\"><\/noscript><\/figure>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.47336561743341404\"  data-type=\"png\" data-w=\"826\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222429150.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.47336561743341404\"  data-type=\"png\" data-w=\"826\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222429150.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u53ef\u4ee5\u770b\u5230\u77ed\u65f6CPU\u548c\u78c1\u76d8\u5360\u7528\u4f1a\u98d9\u9ad8\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u628a\u6279\u5904\u7406\u7684\u91cf\u518d\u8c03\u5927\u4e00\u4e9b\u8c03\u52305000\uff0c\u5728\u6267\u884c\uff1a<\/p>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.8277511961722488\"  data-type=\"png\" data-w=\"418\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222439975.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.8277511961722488\"  data-type=\"png\" data-w=\"418\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222439975.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">13\u79d2\u63d2\u5165\u6210\u529f30\u4e07\u6761\uff0c\u76f4\u63a5\u829c\u6e56\u8d77\u98de\ud83d\udeeb\ud83d\udeeb\ud83d\udeeb<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">JDBC\u5b9e\u73b0\u63d2\u516530\u4e07\u6761\u6570\u636e<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">JDBC\u5faa\u73af\u63d2\u5165\u7684\u8bdd\u8ddf\u4e0a\u9762\u7684mybatis\u9010\u6761\u63d2\u5165\u7c7b\u4f3c\uff0c\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4ee5\u4e0b\u662f Java \u4f7f\u7528 JDBC \u6279\u5904\u7406\u5b9e\u73b0 30 \u4e07\u6761\u6570\u636e\u63d2\u5165\u7684\u793a\u4f8b\u4ee3\u7801\u3002\u8bf7\u6ce8\u610f\uff0c\u8be5\u4ee3\u7801\u4ec5\u63d0\u4f9b\u601d\u8def\uff0c\u5177\u4f53\u5b9e\u73b0\u9700\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><code style=\"overflow-x: auto;padding: 16px;color: #ddd;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #272822;border-radius: 5px;\">\/***JDBC\u5206\u6279\u6b21\u6279\u91cf\u63d2\u5165*@throwsIOException*\/@TestpublicvoidtestJDBCBatchInsertUser()throwsIOException{Connectionconnection=null;PreparedStatementpreparedStatement=null;StringdatabaseURL=<span style=\"color: #a6e22e;line-height: 26px;\">\"jdbc:mysql:\/\/localhost:3306\/test\"<\/span>;Stringuser=<span style=\"color: #a6e22e;line-height: 26px;\">\"root\"<\/span>;Stringpassword=<span style=\"color: #a6e22e;line-height: 26px;\">\"root\"<\/span>;try{connection=DriverManager.getConnection(databaseURL,user,password);\/\/\u5173\u95ed\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\uff0c\u6539\u4e3a\u624b\u52a8\u63d0\u4ea4connection.setAutoCommit(<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">false<\/span>);System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"=====\u5f00\u59cb\u63d2\u5165\u6570\u636e=====\"<\/span>);longstartTime=System.currentTimeMillis();StringsqlInsert=<span style=\"color: #a6e22e;line-height: 26px;\">\"INSERTINTOt_user(username,age)VALUES(?,?)\"<\/span>;preparedStatement=connection.prepareStatement(sqlInsert);Randomrandom=newRandom();<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">for<\/span>(inti=1;i&lt;=300000;i++){preparedStatement.setString(1,<span style=\"color: #a6e22e;line-height: 26px;\">\"\u5171\u996e\u4e00\u676f\u65e0\"<\/span>+i);preparedStatement.setInt(2,random.nextInt(100));\/\/\u6dfb\u52a0\u5230\u6279\u5904\u7406\u4e2dpreparedStatement.addBatch();<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(i%1000==0){\/\/\u6bcf1000\u6761\u6570\u636e\u63d0\u4ea4\u4e00\u6b21preparedStatement.executeBatch();connection.commit();System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165\u7b2c\"<\/span>+i+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6761\u6570\u636e\"<\/span>);}}\/\/\u5904\u7406\u5269\u4f59\u7684\u6570\u636epreparedStatement.executeBatch();connection.commit();longspendTime=System.currentTimeMillis()-startTime;System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6210\u529f\u63d2\u5165 30\u4e07\u6761\u6570\u636e,\u8017\u65f6\uff1a\"<\/span>+spendTime+<span style=\"color: #a6e22e;line-height: 26px;\">\"\u6beb\u79d2\"<\/span>);}catch(SQLExceptione){System.out.println(<span style=\"color: #a6e22e;line-height: 26px;\">\"Error:\"<\/span>+e.getMessage());}finally{<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(preparedStatement!=null){try{preparedStatement.close();}catch(SQLExceptione){e.printStackTrace();}}<span style=\"color: #f92672;font-weight: bold;line-height: 26px;\">if<\/span>(connection!=null){try{connection.close();}catch(SQLExceptione){e.printStackTrace();}}}}<\/code><\/pre>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.55\"  data-type=\"gif\" data-w=\"640\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222442999.gif\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.55\"  data-type=\"gif\" data-w=\"640\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222442999.gif\"><\/noscript><\/figure>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.8349753694581281\"  data-type=\"png\" data-w=\"406\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222445384.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.8349753694581281\"  data-type=\"png\" data-w=\"406\" style=\"display: block;margin-right: auto;margin-left: auto;border-radius: 4px;margin-bottom: 25px;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222445384.png\"><\/noscript><\/figure>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4e0a\u8ff0\u793a\u4f8b\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u901a\u8fc7 JDBC \u8fde\u63a5 MySQL \u6570\u636e\u5e93\uff0c\u5e76\u6267\u884c\u6279\u5904\u7406\u64cd\u4f5c\u63d2\u5165\u6570\u636e\u3002\u5177\u4f53\u5b9e\u73b0\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u83b7\u53d6\u6570\u636e\u5e93\u8fde\u63a5\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u521b\u5efa Statement \u5bf9\u8c61\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u5b9a\u4e49 SQL \u8bed\u53e5\uff0c\u4f7f\u7528 <code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">PreparedStatement<\/code> \u5bf9\u8c61\u9884\u7f16\u8bd1 SQL \u8bed\u53e5\u5e76\u8bbe\u7f6e\u53c2\u6570\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u6267\u884c\u6279\u5904\u7406\u64cd\u4f5c\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u5904\u7406\u5269\u4f59\u7684\u6570\u636e\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u5173\u95ed Statement \u548c Connection \u5bf9\u8c61\u3002<\/section>\n<\/li>\n<\/ul>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u4f7f\u7528<code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">setAutoCommit(false) <\/code>\u6765\u7981\u6b62\u81ea\u52a8\u63d0\u4ea4\u4e8b\u52a1\uff0c\u7136\u540e\u5728\u6bcf\u6b21\u6279\u91cf\u63d2\u5165\u4e4b\u540e\u624b\u52a8\u63d0\u4ea4\u4e8b\u52a1\u3002\u6bcf\u6b21\u63d2\u5165\u6570\u636e\u65f6\u90fd\u65b0\u5efa\u4e00\u4e2a <code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">PreparedStatement<\/code> \u5bf9\u8c61\u4ee5\u907f\u514d\u72b6\u6001\u4e0d\u4e00\u81f4\u95ee\u9898\u3002\u5728\u63d2\u5165\u6570\u636e\u7684\u5faa\u73af\u4e2d\uff0c\u6bcf 10000 \u6761\u6570\u636e\u5c31\u6267\u884c\u4e00\u6b21 <code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">executeBatch()<\/code> \u63d2\u5165\u6570\u636e\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u53e6\u5916\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4f18\u5316\u8fde\u63a5\u6c60\u548c\u6570\u636e\u5e93\u7684\u76f8\u5173\u914d\u7f6e\uff0c\u4ee5\u9632\u6b62\u8fde\u63a5\u8d85\u65f6\u7b49\u95ee\u9898\u3002<\/p>\n<h3 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-bottom: 15px;font-weight: bold;color: black;font-size: 20px;margin-top: 1.2em;\"><span style=\"font-size: 17px;display: inline-block;margin-left: 8px;color: rgb(72, 179, 120);\">\u603b\u7ed3<\/span><\/h3>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5b9e\u73b0\u9ad8\u6548\u7684\u5927\u91cf\u6570\u636e\u63d2\u5165\u9700\u8981\u7ed3\u5408\u4ee5\u4e0b\u4f18\u5316\u7b56\u7565\uff08\u5efa\u8bae\u7efc\u5408\u4f7f\u7528\uff09\uff1a<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\"><strong style=\"line-height: 1.75em;\">1.\u6279\u5904\u7406\uff1a<\/strong> \u6279\u91cf\u63d0\u4ea4SQL\u8bed\u53e5\u53ef\u4ee5\u964d\u4f4e\u7f51\u7edc\u4f20\u8f93\u548c\u5904\u7406\u5f00\u9500\uff0c\u51cf\u5c11\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u6b21\u6570\u3002\u5728Java\u4e2d\u53ef\u4ee5\u4f7f\u7528Statement\u6216\u8005<code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">PreparedStatement<\/code>\u7684<code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">addBatch()<\/code>\u65b9\u6cd5\u6765\u6dfb\u52a0\u591a\u4e2aSQL\u8bed\u53e5\uff0c\u7136\u540e\u4e00\u6b21\u6027\u6267\u884c<code style=\"font-size: 14px;padding: 2px 4px;border-radius: 4px;margin-right: 2px;margin-left: 2px;background-color: rgba(27, 31, 35, 0.05);font-family: &quot;Operator Mono&quot;, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: rgb(40, 202, 113);\">executeBatch()<\/code>\u65b9\u6cd5\u63d0\u4ea4\u6279\u5904\u7406\u7684SQL\u8bed\u53e5\u3002<\/p>\n<ul data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u5728\u5faa\u73af\u63d2\u5165\u65f6\u5e26\u6709\u9002\u5f53\u7684\u7b49\u5f85\u65f6\u95f4\u548c\u6279\u5904\u7406\u5927\u5c0f\uff0c\u4ece\u800c\u907f\u514d\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u7b49\u95ee\u9898\uff1a<\/p>\n<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\"><\/section>\n<\/li>\n<ul style=\"margin-top: 8px;margin-bottom: 8px;padding-left: 25px;color: black;list-style-type: square;\" class=\"list-paddingleft-1\">\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u8bbe\u7f6e\u9002\u5f53\u7684\u6279\u5904\u7406\u5927\u5c0f\uff1a\u6279\u5904\u7406\u5927\u5c0f\u6307\u5728\u4e00\u6b21\u63d2\u5165\u64cd\u4f5c\u4e2d\u63d2\u5165\u591a\u5c11\u884c\u6570\u636e\u3002\u5982\u679c\u6279\u5904\u7406\u5927\u5c0f\u592a\u5c0f\uff0c\u63d2\u5165\u64cd\u4f5c\u7684\u9891\u7387\u5c06\u5f88\u9ad8\uff0c\u800c\u5982\u679c\u6279\u5904\u7406\u5927\u5c0f\u592a\u5927\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u3002\u901a\u5e38\uff0c\u5efa\u8bae\u5c06\u6279\u5904\u7406\u5927\u5c0f\u8bbe\u7f6e\u4e3a1000-5000\u884c\uff0c\u8fd9\u5c06\u51cf\u5c11\u63d2\u5165\u64cd\u4f5c\u7684\u9891\u7387\u5e76\u964d\u4f4e\u5185\u5b58\u5360\u7528\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u91c7\u7528\u9002\u5f53\u7684\u7b49\u5f85\u65f6\u95f4\uff1a\u7b49\u5f85\u65f6\u95f4\u6307\u5728\u6279\u5904\u7406\u64cd\u4f5c\u4e4b\u95f4\u7b49\u5f85\u7684\u65f6\u95f4\u91cf\u3002\u7b49\u5f85\u65f6\u95f4\u8fc7\u77ed\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\uff0c\u800c\u7b49\u5f85\u65f6\u95f4\u8fc7\u957f\u5219\u53ef\u80fd\u4f1a\u5ef6\u8fdf\u63d2\u5165\u64cd\u4f5c\u7684\u901f\u5ea6\u3002\u901a\u5e38\uff0c\u5efa\u8bae\u5c06\u7b49\u5f85\u65f6\u95f4\u8bbe\u7f6e\u4e3a\u51e0\u79d2\u949f\u5230\u51e0\u5341\u79d2\u949f\u4e4b\u95f4\uff0c\u8fd9\u5c06\u4f7f\u64cd\u4f5c\u53d8\u5f97\u5e73\u6ed1\u4e14\u907f\u514d\u51fa\u73b0\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u7b49\u95ee\u9898\u3002<\/section>\n<\/li>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e00\u4e9b\u5185\u5b58\u4f18\u5316\u7684\u6280\u5de7\uff0c\u4f8b\u5982\u4f7f\u7528\u5185\u5b58\u6570\u636e\u5e93\u6216\u4f7f\u7528\u6e38\u6807\u65b9\u5f0f\u63d2\u5165\u6570\u636e\uff0c\u4ee5\u51cf\u5c11\u5185\u5b58\u5360\u7528\u3002<\/section>\n<\/li>\n<\/ul>\n<li>\n<section style=\"margin-top: 5px;margin-bottom: 5px;line-height: 26px;color: rgb(1, 1, 1);\">\n<p style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u603b\u7684\u6765\u8bf4\uff0c\u9009\u62e9\u9002\u5f53\u7684\u6279\u5904\u7406\u5927\u5c0f\u548c\u7b49\u5f85\u65f6\u95f4\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5e73\u7a33\u5730\u8fdb\u884c\u63d2\u5165\u64cd\u4f5c\uff0c\u907f\u514d\u51fa\u73b0\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u7b49\u95ee\u9898\u3002<\/p>\n<\/section>\n<\/li>\n<\/ul>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\"><strong style=\"line-height: 1.75em;\">2.\u7d22\u5f15:<\/strong> \u5728\u5927\u91cf\u6570\u636e\u63d2\u5165\u524d\u6682\u65f6\u53bb\u6389\u7d22\u5f15\uff0c\u6700\u540e\u518d\u6253\u4e0a\uff0c\u8fd9\u6837\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u5199\u5165\u65f6\u5019\u7684\u66f4\u65b0\u7d22\u5f15\u7684\u65f6\u95f4\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\"><strong style=\"line-height: 1.75em;\">3.\u6570\u636e\u5e93\u8fde\u63a5\u6c60\uff1a<\/strong> \u4f7f\u7528\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u53ef\u4ee5\u51cf\u5c11\u6570\u636e\u5e93\u8fde\u63a5\u5efa\u7acb\u548c\u5173\u95ed\u7684\u5f00\u9500\uff0c\u63d0\u9ad8\u6027\u80fd\u3002\u5728\u6ca1\u6709\u4f7f\u7528\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7684\u60c5\u51b5\uff0c\u8bb0\u5f97\u5728finally\u4e2d\u5173\u95ed\u76f8\u5173\u8fde\u63a5\u3002<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-bottom: 8px;padding-top: 1em;color: rgb(74, 74, 74);line-height: 1.75em;\">\u6570\u636e\u5e93\u53c2\u6570\u8c03\u6574\uff1a\u589e\u52a0MySQL\u6570\u636e\u5e93\u7f13\u51b2\u533a\u5927\u5c0f\u3001\u914d\u7f6e\u9ad8\u6027\u80fd\u7684\u78c1\u76d8\u548cI\/O\u7b49\u3002<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"border-top: none;border-right: none;border-bottom: none;font-size: 0.9em;overflow: auto;background: rgb(251, 249, 253);color: rgb(106, 115, 125);margin-bottom: 20px;margin-top: 20px;padding: 15px 20px;line-height: 27px;border-left-color: rgb(53, 179, 120);\">\n<p style=\"line-height: 26px;font-size: 15px;color: rgb(89, 89, 89);\"><span style=\"color: rgb(136, 136, 136);\">\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3aCSDN\u535a\u4e3b\u300c\u5171\u996e\u4e00\u676f\u65e0\u300d\u7684\u539f\u521b\u6587\u7ae0\uff0c\u9075\u5faaCC 4.0 BY-SA\u7248\u6743\u534f\u8bae\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u539f\u6587\u51fa\u5904\u94fe\u63a5\u53ca\u672c\u58f0\u660e\u3002\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/blog.csdn.net\/qq_35427589\/article\/details\/129665307<\/span><\/p>\n<\/blockquote>\n<\/section>\n<section style=\"margin-top: 16px;margin-bottom: 0px;color: rgb(53, 53, 53);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;letter-spacing: 0.8px;white-space: normal;word-spacing: 0.8px;text-align: left;\"><strong><strong style=\"color: rgb(53, 53, 53);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;font-size: 16px;letter-spacing: 0.8px;text-align: left;word-spacing: 0.8px;text-wrap: wrap;\"><\/strong><\/strong><\/section>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u5927\u4fa0\u5b66JAVA              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u8bb2\u8ff0\u901a\u8fc7MyBatis\u3001JDBC\u7b49\u505a\u5927\u6570\u636e\u91cf\u6570\u636e\u63d2\u5165\u7684\u6848\u4f8b\u548c\u7ed3\u679c\u3002 30\u4e07\u6761\u6570\u636e\u63d2\u5165\u63d2\u5165\u6570\u636e\u5e93\u9a8c\u8bc1 \u5b9e\u4f53\u7c7b\u3001mapper\u548c &#8230;<\/p>\n","protected":false},"author":1,"featured_media":5652,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-5722","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433-300x127.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433-300x127.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222243433.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222250859.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222301583.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222301583.png","id":"image3"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222306775.gif","id":"image4"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222306775.gif","id":"image5"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222328842.png","id":"image6"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222328842.png","id":"image7"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222345837.png","id":"image8"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222345837.png","id":"image9"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222355456.png","id":"image10"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222355456.png","id":"image11"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222407440.png","id":"image12"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222407440.png","id":"image13"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222423853.png","id":"image14"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222423853.png","id":"image15"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222429150.png","id":"image16"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222429150.png","id":"image17"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222439975.png","id":"image18"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222439975.png","id":"image19"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222442999.gif","id":"image20"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222442999.gif","id":"image21"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222445384.png","id":"image22"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222445384.png","id":"image23"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2024-08-01","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":358,"next_post_id":5618,"next_post_title":"Spring Boot 3\u89e3\u51b3\u8de8\u57df\u95ee\u9898\u7684\u51e0\u79cd\u65b9\u5f0f","previous_post_id":5824,"previous_post_title":"\u804a\u4e00\u6b21\u7ebf\u7a0b\u6c60\u4f7f\u7528\u4e0d\u5f53\u5bfc\u81f4\u7684\u751f\u4ea7\u6545\u969c","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5722"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5722\/revisions"}],"predecessor-version":[{"id":6280,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5722\/revisions\/6280"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/5652"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}