请教各位高手一个SQL的问题
org.apache.jasper.JasperException: Exception in JSP: /index.jsp:139
136: <UL class=jdul>
137: <%ResultSet rs0=null;
138: rs0=index.select("select top 10 * from zixun where rand=1");
139: while(rs0.next()){%>
140: <LI><%
141: String c=rs0.getString("leixing");
142: if(c.equals("数码")){%><A href="">【数码】</A><%}
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:451)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException org.apache.jsp.index_jsp._jspService(index_jsp.java:191)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
为什会出现这样的错误啊? SQL语句应该没问题吧
------解决方案--------------------139: while(rs0.next()){%>
我觉得既然程序在运行的时候是在这里报的
空指针,那也就是rs0.next指针并没有往下走,说明还是rs0里没有数据所致.所以我觉得最大的原因应该就是sql语句或者那个index.select()方法
------解决方案--------------------
------解决方案--------------------
MYSQL5.0 不支持 top
用limit
select * from zixun where rand=1 limit 10 //取10条