MyBatis直接一次性批量插入30万条,代码如下:
[code]@Testpublic void testBatchInsertUser() throws IOException { InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml"); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream); SqlSession session = sqlSessionFactory.openSession(); System.out.println("===== 开始插入数据 ====="); long startTime = System.currentTimeMillis(); try { List userList = new ArrayList(); for (int i = 1; i yun 4194304). You can change this value on the server by setting the max_allowed_packet’ variable.</p></blockquote>