gpt4 book ai didi

java - 我想使用 Apache POI 将 200k 记录从数据库导出为 .xlsx 文件

转载 作者:行者123 更新时间:2023-12-01 09:19:12 24 4
gpt4 key购买 nike

我想从数据库中将 200k 条记录导出为 .xlsx 文件。我正在使用 Apache POI。 20 分钟后我收到管道损坏异常

file = File.createTempFile("Rule_File", ".xlsx");           
FileOutputStream out = new FileOutputStream(file);
long heapSize = Runtime.getRuntime().totalMemory();
long freeSize = Runtime.getRuntime().freeMemory();
long totalSize = Runtime.getRuntime().maxMemory();
System.out.println("Heap Size = " + heapSize);
System.out.println("freeSize = " + freeSize);
System.out.println("totalSize = " + totalSize);
// ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
//workbook.write(out);

最佳答案

我猜数据库的套接字在 20 分钟后超时。

如果可能,请配置更长的超时。或者您可以以较小的 block 运行脚本,运行时间不超过 20 分钟,然后附加结果?

关于java - 我想使用 Apache POI 将 200k 记录从数据库导出为 .xlsx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40282058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com