首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

求大神看看这是什么东东,好纠结.

2013-07-04 
求大神看看这是什么错误,好纠结..!错误日志:java.sql.SQLException: Illegal operation on empty result s

求大神看看这是什么错误,好纠结..!
错误日志:
java.sql.SQLException: Illegal operation on empty result set.
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:678)
at com.mysql.jdbc.UpdatableResultSet.checkRowPos(UpdatableResultSet.java:239)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:2260)
at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:2372)
at com.trojanwall.dao.trojan.UploadDataDAO.getVo(UploadDataDAO.java:102)
at com.trojanwall.dao.trojan.UploadDataDAO.getVo(UploadDataDAO.java:1)
at com.common.CommonDAO.buildPage_new(CommonDAO.java:218)
at com.common.CommonDAO.query_new(CommonDAO.java:184)
at com.trojanwall.dao.trojan.UploadDataDAO.getTopAll(UploadDataDAO.java:42)
at org.apache.jsp.trojanwall.trojan.report_jsp._jspService(report_jsp.java:1102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.servlet.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)


JAVA JSP ResultSet


[解决办法]
at com.trojanwall.dao.trojan.UploadDataDAO.getVo(UploadDataDAO.java:102)

当你执行查询之后需要rs.next()后才能取值。
例如:


ResultSet rs=stmt.executeQuery("select * from user");
while(rs.next()){
String id= rs.getString("user_id");
String name= rs.getString("user_name");
}

[解决办法]
有可能是因为用PreparedStatement的实例化对象执行executeQuery()时结果集是null,但你仍用了ResultSet,例如:ResultSet rs=pstmt.executeQuery(),然后,while(rs.next()),如果rs==null,当然不能调用next()方法了!

热点排行