请教高手关于数据库中用尽的ResultSet的问题: 40
以下是异常(java.sql.SQLException:用尽的Resultset)的堆栈信息:atoracle.jdbc.dbaccess.DBError.throwSq...
以下是异常(java.sql.SQLException:用尽的 Resultset)的堆栈信息:
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3366)
at oracle.jdbc.driver.OracleStatement.getBytesValue(OracleStatement.java:4746)
at oracle.jdbc.driver.OracleResultSetImpl.getBytes(OracleResultSetImpl.java:632)
at oracle.jdbc.driver.ScrollableResultSet.cacheAllRows(ScrollableResultSet.java:2127)
at oracle.jdbc.driver.ScrollableResultSet.getLastRow(ScrollableResultSet.java:2207)
at oracle.jdbc.driver.ScrollableResultSet.last(ScrollableResultSet.java:510)
at com.gas.service.database.shortsql.ShortSQLDataBaseService.query(ShortSQLDataBaseService.java:241)
at com.htgl.cwt3.trafficstatservices.week_datesource.DateSource_week.getWeekPoliceInfo(DateSource_week.java:859)
at com.htgl.cwt3.trafficstatservices.week_create.C_WeekPolice.creatExl(C_WeekPolice.java:84)
at com.htgl.cwt3.trafficstatservices.starter.RepStarter.runModule(RepStarter.java:93)
at com.gas.platform.module.loader.procedure.ProcedureModuleStartThread.run(ProcedureModuleStartThread.java:81)
2011-02-13 00:23:16.532[错误][16:ShortSQLDataBaseService.query:332] objs:{}
2011-02-13 00:23:16.534[错误][16:C_WeekPolice.creatExl:103] java.sql.SQLException: 用尽的 Resultset
以下是异常(com.gas.service.ServiceException:java.sql.SQLException: 用尽的 Resultset)的堆栈信息:
at com.gas.service.database.shortsql.ShortSQLDataBaseService.query(ShortSQLDataBaseService.java:333)
at com.htgl.cwt3.trafficstatservices.week_datesource.DateSource_week.getWeekPoliceInfo(DateSource_week.java:859)
at com.htgl.cwt3.trafficstatservices.week_create.C_WeekPolice.creatExl(C_WeekPolice.java:84)
at com.htgl.cwt3.trafficstatservices.starter.RepStarter.runModule(RepStarter.java:93)
at com.gas.platform.module.loader.procedure.ProcedureModuleStartThread.run(ProcedureModuleStartThread.java:81)
Caused by: java.sql.SQLException: 用尽的 Resultset
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3366)
at oracle.jdbc.driver.OracleStatement.getBytesValue(OracleStatement.java:4746)
... 9 more
当数据量很大的时候,偶尔会出现这个问题,程序是用rs.last()来获取下一个数据的,连接池的连接数够用,ResultSet也未被关闭,ResultSet也不是空,也不是在集合的尾部数据时出现的问题。真令鄙人绞尽脑汁,大虾指教一二! 展开
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3366)
at oracle.jdbc.driver.OracleStatement.getBytesValue(OracleStatement.java:4746)
at oracle.jdbc.driver.OracleResultSetImpl.getBytes(OracleResultSetImpl.java:632)
at oracle.jdbc.driver.ScrollableResultSet.cacheAllRows(ScrollableResultSet.java:2127)
at oracle.jdbc.driver.ScrollableResultSet.getLastRow(ScrollableResultSet.java:2207)
at oracle.jdbc.driver.ScrollableResultSet.last(ScrollableResultSet.java:510)
at com.gas.service.database.shortsql.ShortSQLDataBaseService.query(ShortSQLDataBaseService.java:241)
at com.htgl.cwt3.trafficstatservices.week_datesource.DateSource_week.getWeekPoliceInfo(DateSource_week.java:859)
at com.htgl.cwt3.trafficstatservices.week_create.C_WeekPolice.creatExl(C_WeekPolice.java:84)
at com.htgl.cwt3.trafficstatservices.starter.RepStarter.runModule(RepStarter.java:93)
at com.gas.platform.module.loader.procedure.ProcedureModuleStartThread.run(ProcedureModuleStartThread.java:81)
2011-02-13 00:23:16.532[错误][16:ShortSQLDataBaseService.query:332] objs:{}
2011-02-13 00:23:16.534[错误][16:C_WeekPolice.creatExl:103] java.sql.SQLException: 用尽的 Resultset
以下是异常(com.gas.service.ServiceException:java.sql.SQLException: 用尽的 Resultset)的堆栈信息:
at com.gas.service.database.shortsql.ShortSQLDataBaseService.query(ShortSQLDataBaseService.java:333)
at com.htgl.cwt3.trafficstatservices.week_datesource.DateSource_week.getWeekPoliceInfo(DateSource_week.java:859)
at com.htgl.cwt3.trafficstatservices.week_create.C_WeekPolice.creatExl(C_WeekPolice.java:84)
at com.htgl.cwt3.trafficstatservices.starter.RepStarter.runModule(RepStarter.java:93)
at com.gas.platform.module.loader.procedure.ProcedureModuleStartThread.run(ProcedureModuleStartThread.java:81)
Caused by: java.sql.SQLException: 用尽的 Resultset
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(OracleStatement.java:3366)
at oracle.jdbc.driver.OracleStatement.getBytesValue(OracleStatement.java:4746)
... 9 more
当数据量很大的时候,偶尔会出现这个问题,程序是用rs.last()来获取下一个数据的,连接池的连接数够用,ResultSet也未被关闭,ResultSet也不是空,也不是在集合的尾部数据时出现的问题。真令鄙人绞尽脑汁,大虾指教一二! 展开
3个回答
展开全部
用Statement st=conn.createStatement();的话
默认是与Statement st=conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
如果想要用rs.last()等方法的话,得设置ResultSet为允许滚动(scrollable),即:
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
当然,也可以用:
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
TYPE_SCROLL_INSENSITIVE 和 TYPE_SCROLL_SENSITIVE的区别是:
前者不会理会其他程序对ResultSet所做的变动,而后者会实时更新其他程序造成的ResultSet变动
默认是与Statement st=conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
如果想要用rs.last()等方法的话,得设置ResultSet为允许滚动(scrollable),即:
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
当然,也可以用:
Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
TYPE_SCROLL_INSENSITIVE 和 TYPE_SCROLL_SENSITIVE的区别是:
前者不会理会其他程序对ResultSet所做的变动,而后者会实时更新其他程序造成的ResultSet变动
追问
这个方法试过了,还是不行,也是偶尔出现
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你不能这样取吗?
String sql="select * from T_messageboard order by messDate desc ";
ResultSet rs=db.executeQuery(sql);
try {
while (rs.next()) {
mess=new MessageBoard();
mess.setMessId(rs.getInt("messId"));
}
} catch (SQLException e) {
e.printStackTrace();
}
或者查询的时候加上数量限制
String sql="select * from T_messageboard order by messDate desc ";
ResultSet rs=db.executeQuery(sql);
try {
while (rs.next()) {
mess=new MessageBoard();
mess.setMessId(rs.getInt("messId"));
}
} catch (SQLException e) {
e.printStackTrace();
}
或者查询的时候加上数量限制
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
boolean last()
将光标移动到此 ResultSet 对象的最后一行
将光标移动到此 ResultSet 对象的最后一行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询