
为了做测试我在本地 mysql 中插入了大量的数据大概几百万
插入的要持续一段时间,但是我发现 java 的写入 mysql 的进程中有多个线程,但是我并没新开线程,只是简单的 for 循环
是 mysql 驱动中插入的过程会多开线程吗?
Connection cOnnection= DB.getConnection(); PreparedStatement statement = null; try { cOnnection= DB.getConnection(); for (int i = 0; i < 10000000; i++) { String sql = "insert into post( title, uid, col1, col2, col3, col4) value(?,?,?,?,?,?)"; statement = connection.prepareStatement(sql); String str = getRandomString(64); statement.setString(1, getRandomString(16)); statement.setInt(2, random.nextInt(15792992)); statement.setString(3, str); statement.setString(4, str); statement.setString(5, str); statement.setString(6, str); statement.execute(); } } catch (Exception e) { e.printStackTrace(); }