|
@@ -39,11 +39,13 @@ public class CutExamOfflineDataService {
|
|
"from ec_oe_exam_record_4_marking where offline_file_name is not null";
|
|
"from ec_oe_exam_record_4_marking where offline_file_name is not null";
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+
|
|
Connection connection = jdbcTemplate.getDataSource().getConnection();
|
|
Connection connection = jdbcTemplate.getDataSource().getConnection();
|
|
//流式读取数据
|
|
//流式读取数据
|
|
PreparedStatement ps = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
|
|
PreparedStatement ps = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY,
|
|
ResultSet.CONCUR_READ_ONLY);
|
|
ResultSet.CONCUR_READ_ONLY);
|
|
ps.setFetchSize(Integer.MIN_VALUE);
|
|
ps.setFetchSize(Integer.MIN_VALUE);
|
|
|
|
+ log.info("开始流式读取数据....");
|
|
ResultSet rs = ps.executeQuery(sql);
|
|
ResultSet rs = ps.executeQuery(sql);
|
|
|
|
|
|
int count = 0;
|
|
int count = 0;
|
|
@@ -78,7 +80,7 @@ public class CutExamOfflineDataService {
|
|
offlineFileUrl, fileType, suffix, creationTime, updateTime});
|
|
offlineFileUrl, fileType, suffix, creationTime, updateTime});
|
|
count++;
|
|
count++;
|
|
|
|
|
|
- log.info("[CutExamOfflineDataService]. count=" + count);
|
|
|
|
|
|
+// log.info("[CutExamOfflineDataService]. count=" + count);
|
|
|
|
|
|
//每500条数据执行一次批量插入操作
|
|
//每500条数据执行一次批量插入操作
|
|
if (count % 500 == 0) {
|
|
if (count % 500 == 0) {
|
|
@@ -93,11 +95,10 @@ public class CutExamOfflineDataService {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- count = 0;
|
|
|
|
dataList = new ArrayList<>();
|
|
dataList = new ArrayList<>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- log.info("数据遍历完成,多线程插入数据中...");
|
|
|
|
|
|
+ log.info(String.format("数据遍历完成,多线程插入数据中...共计%s条数据,共需执行%s个批次的插入动作", count, (count / 500 + 1)));
|
|
|
|
|
|
//剩下的最后一批次的数据单独执行
|
|
//剩下的最后一批次的数据单独执行
|
|
if (dataList.size() > 0) {
|
|
if (dataList.size() > 0) {
|