日期:2014-05-17  浏览次数:20890 次

数据库操作
String name;
name="13";
ResultSet rs = DBBean.query("select * from book where bookid='name'");
rs.next();
// while(rs.next()) 
//{
String check1="",check2="",check3="",check4="",check5="";
String radio1="",radio0="",radio=rs.getString("sex");
String str=rs.getString("testbox");
这儿的数据库语句有问题吗?异常显示在下面,把name直接改成13就没问题,不解

org.apache.jasper.JasperException: An exception occurred processing JSP page /show.jsp at line 40

37: // while(rs.next()) 
38: //{
39: String check1="",check2="",check3="",check4="",check5="";
40: String radio1="",radio0="",radio=rs.getString("sex");
41: String str=rs.getString("testbox");
42: String[] strs=str.split("a");
43: if (radio.equals("1")) radio1="checked";else radio0="checked";

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

javax.servlet.ServletException: java.sql.SQLException: Illegal operation on empty result set.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.show_jsp._jspService(show_jsp.java:177)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.sql.SQLException: Illegal operation on empty result set.
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:685)
com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5476)
com.mysql.jdbc.ResultSet.getString(ResultSet.java:5420)
com.mysql.jdbc.ResultSet.getString(ResultSet.java:5436)
org.apache.jsp.show_jsp._jspService(show_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.