我想从数据库中将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分钟后会超时。
如果可能,请配置更长的超时时间。还是可以在不到20分钟的时间内运行较小的脚本,然后附加结果?