查询数据库的问题,急,再线等

linkist 2003-03-27 02:15:13
做一程序,实现模糊查询并显示出数据项,程序如下
<%
String keyword,way;
String strSQL;
keyword=request.getParameter("keyword");
keyword=getStr(keyword);
strSQL="select * from goods where name like '%"+keyword+"%'";


ResultSet RSa = searchbean.executeQuery(strSQL);
int searchnum;

searchnum=0;
while (RSa.next()) {

String srch_title,comefrom;
int cate,id;
id=RSa.getInt("id");
srch_title=RSa.getString("name");
comefrom=RSa.getString("comefrom");
cate=RSa.getInt("category");
out.println("<tr height='23'><td>");
out.println("<li><a href=javascript:show('../webshop/details.jsp?id="+id+"','详细资料',480,500)>"+srch_title+"</a>");
out.println("</td>");
out.println("<td>"+comefrom+" </td>");
//out.println("<td>"+category(cate)+"</td>");
out.println("<td><a href=javascript:show('../webshop/details.jsp?id="+id+"','详细资料',480,500)>[详细资料]</a></td>");
out.println("</tr>");

searchnum=searchnum+1;
%>

其中的getStr可以正确的得到项的值,而一添加getInt想得到INT类型的数值的时候就报错,错误信息如下

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

exception

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.search1$jsp._jspService(search1$jsp.java:200)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:484)

请问到底是怎么回事啊,请务必帮忙!!!

...全文
6 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
linkist 2003-03-27
好了,谢谢acefr(),十分感谢
回复
acefr 2003-03-27
比如数据库中是按照name,id...这样的,那么你就要rs.getString("name")然后才能rs.getInt("id")
回复
linkist 2003-03-27
那应该怎么实现呢 ??
回复
acefr 2003-03-27
也就是说,你现在是用select * from.....
你读取字段一定要按顺序来。
回复
linkist 2003-03-27
顺序是什么意思啊 ,能不能说清楚一点!!
谢谢!
回复
acefr 2003-03-27
注意rs.getInt()的顺序。
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-03-27 02:15
社区公告
暂无公告