java.sqlExcetion [microsoft ODBC Driver]非法的游标状态大多是没有在while(rs.next()){} block里面来对rs进行操作 比如: rs = psmt.excuteQuery(); String s = rs.getString("");因为rs最开始指向的并不是结果集的首行,而是首行之前(我估计是个结果集头之类的东西)看帮助文档有: A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on. 对ResultSet进行处理,别忘了先定位到结果集上
java.sqlExcetion [microsoft ODBC Driver]非法的游标状态各位大哥 小弟实在不解啊
是我的sql语句写错了
还是 我的select 语句有问题啊
我的思路是
先查询出所有对主题文章(老师写)提出疑问的文章(学生写);
查询的结果有多条纪录比如有3条吧
然后老师可能对有些提出的文章进行回复
所以又要进行查询
对第一条进行查询的时候(查询对第一条纪录也就是第一个学生疑问进行回复的老师文章)
查询完后
要查询第二条
如此一直到第三条
可这个过程是不是要用到游标啊
就是EXEC SQL DECLARE 游标名 <sql语句>
这种游标啊
不这样行不行啊
.....}就行
比如:
rs = psmt.excuteQuery();
String s = rs.getString("");因为rs最开始指向的并不是结果集的首行,而是首行之前(我估计是个结果集头之类的东西)看帮助文档有:
A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on. 对ResultSet进行处理,别忘了先定位到结果集上
下午我刚碰到这个问题,查询的返回ResultSet,这时游标是在第一行之前,要ResultSet.next()一次才能指向第一行
郁闷了我好久也找不出原因,刚想出来问问!@@@我先试试!!谢谢了