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

数据查询while(rs.next)错误
学习jsp 写在线书店的查询的时候出错了 不知道怎么办了
这个是现实错误代码org.apache.jasper.JasperException: An exception occurred processing JSP page /search.jsp at line 62

59: myPage.pageId=1;
60: Vector idList=new Vector();
61: getPage="1";
62: while(rs.next())
63: {
64: myPage.recordCount++;
65: if(myPage.recordCount==myPage.pageSize)




源文件代码

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<SCRIPT language=JavaScirpt src="JSLib.js" type="text/javascript"></SCRIPT>
<SCRIPT language=JavaScript>
function checkform(Frm){
  var flag=ture;
  if(isInt(Frm.pageId.value))
  {
  alert("用户名不能为空!");
  Frm.pageId.focus();
  flag=false;
  }
  retrun flag;
}
function detail(a)
{
  windows.open("detail.jsp?pid="+a,"body","toolbar=no,left=150,top=20,width=480,height=350,meaubar=no,systemMenu=no");
}
function add(a)
{
  windows.open("add.jsp?pid="+a,"body","toobar=no,left=150,top=20,width=300,height=50,menubar=no,systemMenu=no");
   
}

</script>
<%@ page import="java.sql.*" %>
<%@ page import="page.Page"%>
<jsp:useBean id="db" scope="page" class="opendb.opendb"/>
<%
String getPage=request.getParameter("pageId").trim();
if(getPage.compareTo("-1")==0)
{
  Page myPage=new Page();
  String bookname=request.getParameter("bookname").trim();
  String author=request.getParameter("author").trim();
  String nameSelect="";
  String authorSelect="";
  if(bookname.compareTo("")!=0) nameSelect="bookname like'%"+bookname+"%'";
  if(author.compareTo("")!=0) authorSelect="author like'%"+author+"%'";
  byte[] tmpbyte=nameSelect.getBytes("ISO8859_1");
  nameSelect=new String(tmpbyte);
  tmpbyte=authorSelect.getBytes("ISO8859_1");
  authorSelect=new String(tmpbyte);
  if(authorSelect.compareTo("")!=0&&nameSelect.compareTo("")!=0)nameSelect="and"+nameSelect;
  String sql="select pid frombook where";
  sql=sql+authorSelect+nameSelect+"order by pid desc";
  session.putValue("authorSelect", authorSelect);
  session.putValue("nameSelect", nameSelect);
  ResultSet rs=db.executeQuery(sql);
  myPage.recordCount=0;
  myPage.pageSize=10;
  myPage.pageCount=0;
  myPage.pageId=1;
  Vector idList=new Vector();
  getPage="1";
  while(rs.next())
  {
  myPage.recordCount++;
  if(myPage.recordCount==myPage.pageSize)
  {  
  myPage.pageCount++;
  idList.addElement(rs.getString("pid"));
  myPage.recordCount=0;