Topic: 关闭的resultset异常 |
Print this page |
1.关闭的resultset异常 | Copy to clipboard |
Posted by: king_wjb Posted on: 2006-12-25 11:14 我在程序中写了一段如下的代码: conn = ConnectDB.getDBConnection(); ps = conn.prepareStatement(strSql); rs = ps.executeQuery(); while (rs.next()) { r_data.set_alarm_level_id(rs.getString("ID")); try { if (rs != null) rs.close(); if (ps != null) ps.close(); } catch (Exception e) { e.printStackTrace(); } ps = conn.prepareStatement(strSql2); rs = ps.executeQuery(); while (rs.next()) { r_data.set_sound_alarm_level_id(rs.getString("ID")); } } 实际上strSql与strSql2都只有一条记录,结果在运行时经常会出现:关闭的resultset,无效的next()异常。请问应该如何解决? (注,此段代码会定时周期执行,有时候出现异常,有时候没有) |
2.Re:关闭的resultset异常 [Re: king_wjb] | Copy to clipboard |
Posted by: cxp108 Posted on: 2006-12-25 11:35 如果数据库没有问题的话,很可能是你对conn,ps,rs这几个对象进行了多线程操作,其中有关闭的动作。 |
3.Re:关闭的resultset异常 [Re: king_wjb] | Copy to clipboard |
Posted by: king_wjb Posted on: 2006-12-25 11:43 但是为什么是偶尔出现呢 |
4.Re:关闭的resultset异常 [Re: king_wjb] | Copy to clipboard |
Posted by: cxp108 Posted on: 2006-12-26 12:57 没看代码很难说.... |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |