运行一段时间以后,老是报错,超出游标最大速,但是分页查询的时候都限制在500以内。
以下是封装的方法,定时器定时调用:
public List<NDDriverInfo> queryDriverInfo(String ticketTakeSeq) throws Exception{ List<NDDriverInfo> carInfos = new ArrayList<NDDriverInfo>(); StringBuffer strSql = new StringBuffer(); try { strSql.append("SELECT * FROM.......where rn between 0 and 300"); PreparedStatemen tstmt=conn.prepareStatement(strSql.toString()); stmt.setString(1, ticketTakeSeq); ResultSet rs = stmt.executeQuery(); while (rs.next()){ NDDriverInfo info=new NDDriverInfo(); info.setExtractSeq(rs.getString("extract_seq")); info.setCZDM(rs.getString("machinery_id")); //车站代码 info.setCZMC(rs.getString("mac_name")); // info.setID(rs.getString("table_seq")); info.setJSZYXQ(rs.getString("drivergrade_valid")); info.setXM(rs.getString("driver_name")); info.setZHXGSJ(rs.getString("lastupdate_time")); info.setZJHM(rs.getString("identity_id")); info.setZJLX("身份证"); info.setZT(rs.getString("driver_state")); carInfos.add(info); } rs.close(); stmt.close(); conn.commit(); } catch (SQLException e) { throw new Exception("查询中心信息失败"+e.getMessage()); } return carInfos; }
下边是错误信息:
java.lang.Exception: 查询中心信息失败ORA-00604: 递归 SQL 级别 1 出现错误 ORA-01000: 超出打开游标的最大数 ORA-00604: 递归 SQL 级别 1 出现错误 ORA-01000: 超出打开游标的最大数 ORA-01000: 超出打开游标的最大数 at com.dao.PoliceDao.queryDriverInfo(PoliceDao.java:311) at com.ui.Main.driverInfoToFile(Main.java:788) at com.ui.Main.access$8(Main.java:782) at com.ui.Main$7$1.run(Main.java:359) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) at com.ui.Main.createComp(Main.java:313) at com.ui.Main.main(Main.java:74)
已经尝试过修改最大游标数:
通过命令修改 alter system set open_cursors=1000;
但是并没有commit;
这个分析参考 https://www.cnblogs.com/leipei2352/archive/2011/06/14/2080575.html