MyBatis ExecutorType.BATCH 报ORA-01000: 超出打开游标的最大数的解决。
1、登陆以dba管理角色权限登陆oracle,修改oracle默认游标最大数。
查看当前打开的游标数目
select count(*) from v$open_cursor;
修改Oracle最大游标数
alter system set open_cursors=1000 scope=both;
2、修改代码
最快捷方式修改 ExecutorType.BATCH 处理方式:
修改前:
batchSession = sessionFactory.openSession(ExecutorType.BATCH, session.getConnection());
修改后(手动提交):
batchSession = sessionFactory.openSession(false);
PreparedStatement prest = session.getConnection().prepareStatement(
commitFetchFrameSql, ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
for (FetchFrame fetchFrame : foundFrames) {
prest.setInt(1, fetchFrame.getState().getIndex());
prest.setTimestamp(2, new Timestamp(fetchFrame
.getRetrieveTime().getTime()));
prest.setInt(3, fetchFrame.getActualSpecsvsId());
prest.setLong(4, fetchFrame.getId());
prest.addBatch();
}
int[] executeBatch = prest.executeBatch();