Can not issue empty query郁闷到何时啊?请进,谢
条件查询页面:
<html>
<body>
<center>查询书籍信息</center>
<hr size=5 color="445566">
<center>
<form action="search.jsp" method="post">
<p><input type=submit value="查询所有"></p>
</form>
<center>
<form name="form1"action=result.jsp method="post">
<p>请选择查询条件:<br>
<select name="selectedtype" size="1" >
<option value="ID">ID</option>
<option value="name">name</option>
<option value="auther">auther</option>
<option value="publisher">publisher</option>
<option value="time">time</option>
<option value="all">all</option>
</select></p>
<p>关键字<br>
<input type="text" name="keyword" size=20></p>
<p><input type=submit value=submit></p>
</form>
</center>
</body>
</html>
jsp页面:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%@ include file="conn1.jsp"%>
<% String id=request.getParameter("ID");
String name=request.getParameter("name");
String auther=request.getParameter("auther");
String publisher=request.getParameter("publisher");
String time1=request.getParameter("time");
String all=request.getParameter("all");
String keyword=request.getParameter("keyword");
String sql = "";
if (id!=null && id.equals("")) { sql="select * from info where ID='"+keyword+"'"; }
else if(name!=null && !name.equals("")){ sql="select * from info where name like'"+keyword+"'"; }
else if( auther!=null && auther.equals("")){ sql="select * from info where auther'"+keyword+"'"; }
else if(publisher!=null && publisher.equals("")){ sql="select * from info where publisher='"+keyword+"'"; }
else if(time1!=null && time1.equals("")) { sql="select * from info where time='"+keyword+"'"; }
else if(all!=null && all.equals("")){ sql="select * from info "; }
out.println(sql);
ResultSet rs=st.executeQuery(sql);
out.println("数据库操作成功,查询结果如下:");
out.println("<table width=50% border=3> ");
out.println("<tr><td>"+"ID"+"</td><td>"+"name"+"</td><td>"+"auther"+"</td><td>"+"publisher"+"</td><td>"+"time"+"</td></tr>");
while(rs.next()) {
String col1 =rs.getString(1);
String col2 =rs.getString(2);
String col3 =rs.getString(3);
String col4 =rs.getString(4);
String col5 =rs.getString(5);
out.println("<tr><td>"+col1+"</td><td>"+col2+"</td><td>"+col3+"</td><td>"+col4+"</td><td>"+col5+"</td></tr>");
}
out.println("</table>");
{%> <%}
%>
<%
rs.close();
st.close();
con.close();
%>
<html>
<form name="form" method="post" action="query.html">
<input type="submit" name="summit" value="返回" >
</html>
错误信息:
javax.servlet.ServletException: Can not issue empty query
弄了好久都没通,俺知道这对高手来说是小儿科,我初学,没办法阿,帮忙调一下程序,谢谢,谢谢