使用批量处理的方式提高效率
connection.setAutoCommit(false) //设置手动提交 val sql = "xxxx" pstmt = connection.prepareStatement(sql) for (ele <- list){ ······ pstmt.addBatch() } pstmt.executeBatch() //执行批处理 connection.commit() //手动提交
使用批量处理的方式提高效率
connection.setAutoCommit(false) //设置手动提交 val sql = "xxxx" pstmt = connection.prepareStatement(sql) for (ele <- list){ ······ pstmt.addBatch() } pstmt.executeBatch() //执行批处理 connection.commit() //手动提交