输入查询条件查询数据库出错 谁能帮忙看看那里出问题了

Makaveli 2007-06-18 10:31:17
通过输入框选择输入查询条件转向查询页面后出错 谁能帮忙看看那里出问题了
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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





Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


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


--------------------------------------------------------------------------------

Apache Tomcat/5.5.23
...全文
359 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxs731 2007-06-19
  • 打赏
  • 举报
回复
<jsp:useBean id="dbutil" scope="request" class="javabean.dbutil"/>
没错吗?建议从这句开始debug。
Makaveli 2007-06-19
  • 打赏
  • 举报
回复
现在倒是没有错误了 但是查询后没有数据显示了
Makaveli 2007-06-18
  • 打赏
  • 举报
回复
谁能帮帮忙 调了好久都调不好
Makaveli 2007-06-18
  • 打赏
  • 举报
回复
ljzhrkkk()
那应该怎么改下?

superjava_2006 2007-06-18
  • 打赏
  • 举报
回复
<%ResultSet rs=dbutil.query(sql);
if((rs!=null)&&(!rs.isLast())){
while(rs.next()){
%>
<tr bgcolor="#dddddd">
<td bgcolor="#dddddd"><div align="center"><%=rs.getString("bookid") %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getSting("book_type")) %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getString("book_name")) %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getString("book_author")) %></div></td>

</tr>
<% }//最后的这段代码,看这里是不是少了个花括号呢?(if的一个,while的一个,你现在只有一个)
%>



</body>
</html>
再就是你输入查询条件的那个页面,图书的类型、名称、作者怎么用那几个运算符比较??
ljzhrkkk 2007-06-18
  • 打赏
  • 举报
回复
sql="select * from bookinfo where "+sel_type+sel_comp+"'"+sel_type_value+"'";
SQL语句有问题!
Makaveli 2007-06-18
  • 打赏
  • 举报
回复
这个是查询条件的代码:<%@ page contentType="text/html;charset=gb2312"%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<title>图书信息查询</title>
<style type="text/css">
<!--
.style1{font-size:24px}
</style>
</head>
<body align="center">
<div align="center">
<p>
<span class="style1"> 图书信息查询更新系统 </span></p>
<form action="chaxun.jsp" method="post" name="form1" target="_self">
<div align="left">
<p align="center">
<label>输入查询条件
<select name="type">
<option value="bookid" selected>图书编号</option>
<option value="book_type">图书类型</option>
<option value="book_name">图书名称</option>
<option value="book_author">图书作者</option>
</select>
<select name="comp">
<option value=">=" selected>>=</option>
<option value="<="><=</option>
<option value="=">=</option>
</select>
<input name="typevalue" type="text" size="20" maxlength="20">
</label>
</p>
<p align="center">
<label>
<input type="submit" name="Submit" value="提交">
<input name="reset" type="reset" id="reset" value="重置">
</label>
</p>
</div>
</form>
<p>
</p>
</div>
</body>
</html>

这个是查询结果显示的代码:
<%@ page contentType="text/html;charset=gb2312" errorPage="" language="java"%>
<%@ page import="java.sql.*" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图书查询管理系统</title>
<jsp:useBean id="dbutil" scope="request" class="javabean.dbutil"/>
<style type="text/css">
<!--
.style1{font-size:24px}
.style2{font-size:18px}
-->
</style>
</head>
<%
dbutil.connect();
String sel_type;
String sel_comp;
String sel_type_value;
String sql;
//获取请求参数
sel_type=request.getParameter("type");
sel_comp=request.getParameter("comp");
sel_type_value=request.getParameter("typevalue");
sql="select * from bookinfo where "+sel_type+sel_comp+"'"+sel_type_value+"'";
%>
<body>
<div align="center" class="style1">查询结果</div>

<table width="700" border="1" align="center" bordercolor="#000000" bgcolor="#cccccc">
<tr>
<th scope="col">图书编号</th>
<th scope="col">图书类型</th>
<th scope="col">图书名称</th>
<th scope="col">图书作者</th>

</tr>
<%ResultSet rs=dbutil.query(sql);
if((rs!=null)&&(!rs.isLast())){
while(rs.next()){
%>
<tr bgcolor="#dddddd">
<td bgcolor="#dddddd"><div align="center"><%=rs.getString("bookid") %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getSting("book_type")) %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getString("book_name")) %></div></td>
<td bgcolor="#dddddd"><div align="center"><%=new String(rs.getString("book_author")) %></div></td>

</tr>
<% }
%>



</body>
</html>

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧