Topic: 查询数据库查询出错,请高用指点! |
Print this page |
1.查询数据库查询出错,请高用指点! | Copy to clipboard |
Posted by: linkeca Posted on: 2005-10-26 17:00 查询书目程序: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%@ page import="java.sql.*" contentType="text/html;charset=GB2312" %> <jsp:useBean id="pool" scope="session" class="text.check"/> <%request.setCharacterEncoding("gb2312");%> <html> <head> <title>查询结果</title> </head> <body> <% ResultSet rs1,rs2; String search_str,sql1,temp,choice; String SearchType=request.getParameter("SearchType"); //int i=stringToInt(SearchType); int i=1; choice=request.getParameter("match_flag"); search_str=request.getParameter("search_str"); //SearchType=request.getParameter("SearchType"); Integer p=Integer.valueOf(SearchType); i=p.intValue(); if(choice=="0") temp=search_str+"%"; else temp="%"+search_str+"%"; String str1; switch { case 1://书名; sql1="select * from book_msg where book_name like '"+temp+"'"; break; case 2://作者 sql1="select * from book_msg where book_author like '"+temp+"'"; break; case 3://出版社 sql1="select * from book_msg where book_publisher like '"+temp+"'"; break; case 4://分类号 sql1="select * from book_msg where book_type like '"+temp+"'"; break; default: sql1="select * from book_msg"; } pool.getSQL(sql1); rs1=pool.buildlink(); %> <table border="1"> <tr> <td>图书编号</td> <td>图书名</td> <td>图书状态</td> <td>作者</td> <td>出版社</td> <td>还书时间</td> </tr> <% while(rs1.next()) { %><tr><% %><td><%=rs1.getString("book_id")%> </td><% %><td><%=rs1.getString("book_name")%> </td><% if(rs1.getInt("book_state")==1) %><td>借出 </td><% else %><td>在馆 </td><% %><td><%=rs1.getString("book_author")%> </td><% %><td><%=rs1.getString("book_publisher")%> </td><% %><td><%=rs1.getString("book_returntime")%> </td><% %></tr><% } %></table><% %> </body> </html> 出错信息: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) org.apache.jsp.shumuchaxun.forsearch_jsp._jspService(forsearch_jsp.java:167) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) javax.servlet.http.Http Servlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) |
2.Re:查询数据库查询出错,请高用指点! [Re: linkeca] | Copy to clipboard |
Posted by: 沙漠小鸟 Posted on: 2005-10-26 18:06 类型出错! |
3.Re:查询数据库查询出错,请高用指点! [Re: linkeca] | Copy to clipboard |
Posted by: linkeca Posted on: 2005-10-27 12:55 请高手指点怎样修改? 具体那个类型出错? |
4.Re:查询数据库查询出错,请高用指点! [Re: linkeca] | Copy to clipboard |
Posted by: pp_car Posted on: 2005-10-30 14:04 是不是pool.getSQL(sql1)这句应该为pool.setSQL(sql1)呀? 如果不是,请在提交查询语句前输出查询语句。并在类型装换语句上加上try。。。catch。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |