jdbc Operation not allowed after ResultSet closed 出现这个错误 5
main函数ResultSetrs=st.executeQuery("select*fromform_urlwheresaveisNULL");while(rs.next...
main函数
ResultSet rs=st.executeQuery("select * from form_url where save is NULL");
while(rs.next()){
url1=rs.getString("url");
id=getInt("id");
test.downloadFile(url1,st,id);
}
downloadfile函数中
st.executeUpdate("update form_url set save_path = 12 where id = id");
具体错误如下
Operation not allowed after ResultSet closed
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:666)
at com.mysql.jdbc.ResultSet.next(ResultSet.java:7274)
at liuyi.test.main(test.java:86) 展开
ResultSet rs=st.executeQuery("select * from form_url where save is NULL");
while(rs.next()){
url1=rs.getString("url");
id=getInt("id");
test.downloadFile(url1,st,id);
}
downloadfile函数中
st.executeUpdate("update form_url set save_path = 12 where id = id");
具体错误如下
Operation not allowed after ResultSet closed
java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:666)
at com.mysql.jdbc.ResultSet.next(ResultSet.java:7274)
at liuyi.test.main(test.java:86) 展开
2个回答
展开全部
错误上说你ResultSet 已经关了,不能操作了。你应该是换了执行语句所以ResultSet 关了,我记得ResultSet 的实现是基于游标的,换了查询游标就更新了吧。
你可以试试建个st2,来传到downloadFile里面。
你可以试试建个st2,来传到downloadFile里面。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
main函数
ResultSet rs=st.executeQuery("select * from form_url where save is NULL");
while(rs.next()){
url1=rs.getString("url");
id=getInt("id");
test.downloadFile(url1,st,id);
}
rs.rs.close();
ResultSet rs=st.executeQuery("select * from form_url where save is NULL");
while(rs.next()){
url1=rs.getString("url");
id=getInt("id");
test.downloadFile(url1,st,id);
}
rs.rs.close();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询