当前位置: 代码迷 >> J2EE >> 查询数据出错,请高手帮忙!解决方法
  详细解决方案

查询数据出错,请高手帮忙!解决方法

热度:134   发布时间:2016-04-22 03:12:38.0
查询数据出错,请高手帮忙!
问题:
<%
//数据库已经连接上

String check =request.getParameter("check");
  sql="select * from students where Snumber='"+check+"' ;
  rs =smt.executeQuery(sql);
  while(rs.next()){%>
<td><%=rs.getString("Snumber")%></td>

  <%}
conn.close();
rs.close();
smt.close();
%>
可是不能打印出结果,却显示下面的出错信息,请高手指教,不甚感激!出错信息如下:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 22 in the jsp file: /showresult.jsp
Generated servlet error:
String literal is not properly closed by a double-quote


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 22 in the jsp file: /showresult.jsp
Generated servlet error:
String literal is not properly closed by a double-quote


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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



------解决方案--------------------
sql="select * from students where Snumber='"+check+"' ; 
看是不是这的问题,半边分号
------解决方案--------------------
你这样改一下吧
 sql="select * from students where Snumber='"+check+"' ; 

改为:
 sql="select * from students where Snumber='"+check+"'";

------解决方案--------------------
sql="select * from students where Snumber='"+check+"' ; 
改为
sql="select * from students where Snumber="+check ; 

代码迷推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.daimami.com/search?q=2308
  相关解决方案