suoyin_result.jsp
上传用户:cnkaiguan
上传日期:2014-08-25
资源大小:5403k
文件大小:4k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@page contentType="text/html;charset=gbk" %>
  2. <%@page import="java.sql.*" %>
  3. <%
  4. String skey=request.getParameter("keyword");
  5. String key=new String(skey.getBytes("iso-8859-1"));
  6. String select=request.getParameter("select");
  7. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  8. Connection con=DriverManager.getConnection("jdbc:odbc:booksystem");
  9. Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
  10. out.print("<table border>");
  11. out.print("<tr>");
  12. out.print("<th width=72>图书编号</td>");
  13.     out.print("<th width=72>图书类别</td>");
  14.     out.print("<th width=68>图书名称</td>");
  15.     out.print("<th width=62>作者</td>");
  16.     out.print("<th width=70>供应商</td>");
  17.     out.print("<th width=84>出版日期</td>");
  18.     out.print("<th width=54>售价</td>");
  19.     out.print("<th width=65>库存量</td>");
  20.     out.print("<th width=50>是否发布</td>");
  21.     out.print("<th width=50>是否热点书</td>");
  22.     out.print("<th width=52>销售量</td>");
  23. out.print("<tr>");
  24. if(select.equals("idbook"))
  25. {
  26. ResultSet rs=sql.executeQuery("select * from books where idbook like '%"+key+"%'");
  27. if(rs.next())
  28. rs.previous();
  29. while(rs.next())
  30. {
  31. String a,b,c,d,e,f,g,h,i,j,k;
  32. a=rs.getString(1);
  33. out.print("<td>"+a+"</td>");
  34. b=rs.getString(2);
  35. out.print("<td>"+b+"</td>");
  36. c=rs.getString(3);
  37. out.print("<td>"+c+"</td>");
  38. d=rs.getString(4);
  39. out.print("<td>"+d+"</td>");
  40. e=rs.getString(5);
  41. out.print("<td>"+e+"</td>");
  42. f=rs.getString(6);
  43. out.print("<td>"+f+"</td>");
  44. g=rs.getString(7);
  45. out.print("<td>"+g+"</td>");
  46. h=rs.getString(8);
  47. out.print("<td>"+h+"</td>");
  48. i=rs.getString(9);
  49. out.print("<td>"+i+"</td>");
  50. j=rs.getString(10);
  51. out.print("<td>"+j+"</td>");
  52. k=rs.getString(11);
  53. out.print("<td>"+k+"</td>");
  54. out.print("<tr>");
  55.       }
  56. }
  57. else
  58. if(select.equals("categoryname"))
  59. {
  60. ResultSet rs=sql.executeQuery("select * from books where categoryname like '%"+key+"%'");
  61. if(rs.next())
  62. rs.previous();
  63. while(rs.next())
  64. {
  65. String a,b,c,d,e,f,g,h,i,j,k;
  66. a=rs.getString(1);
  67. out.print("<td>"+a+"</td>");
  68. b=rs.getString(2);
  69. out.print("<td>"+b+"</td>");
  70. c=rs.getString(3);
  71. out.print("<td>"+c+"</td>");
  72. d=rs.getString(4);
  73. out.print("<td>"+d+"</td>");
  74. e=rs.getString(5);
  75. out.print("<td>"+e+"</td>");
  76. f=rs.getString(6);
  77. out.print("<td>"+f+"</td>");
  78. g=rs.getString(7);
  79. out.print("<td>"+g+"</td>");
  80. h=rs.getString(8);
  81. out.print("<td>"+h+"</td>");
  82. i=rs.getString(9);
  83. out.print("<td>"+i+"</td>");
  84. j=rs.getString(10);
  85. out.print("<td>"+j+"</td>");
  86. k=rs.getString(11);
  87. out.print("<td>"+k+"</td>");
  88. out.print("<tr>");
  89.       }
  90. }
  91. else
  92. if(select.equals("bookname"))
  93. {
  94. ResultSet rs=sql.executeQuery("select * from books where bookname like '%"+key+"%'");
  95. if(rs.next())
  96. rs.previous();
  97. while(rs.next())
  98. {
  99. String a,b,c,d,e,f,g,h,i,j,k;
  100. a=rs.getString(1);
  101. out.print("<td>"+a+"</td>");
  102. b=rs.getString(2);
  103. out.print("<td>"+b+"</td>");
  104. c=rs.getString(3);
  105. out.print("<td>"+c+"</td>");
  106. d=rs.getString(4);
  107. out.print("<td>"+d+"</td>");
  108. e=rs.getString(5);
  109. out.print("<td>"+e+"</td>");
  110. f=rs.getString(6);
  111. out.print("<td>"+f+"</td>");
  112. g=rs.getString(7);
  113. out.print("<td>"+g+"</td>");
  114. h=rs.getString(8);
  115. out.print("<td>"+h+"</td>");
  116. i=rs.getString(9);
  117. out.print("<td>"+i+"</td>");
  118. j=rs.getString(10);
  119. out.print("<td>"+j+"</td>");
  120. k=rs.getString(11);
  121. out.print("<td>"+k+"</td>");
  122. out.print("<tr>");
  123.       }
  124. }
  125. con.close();
  126. %>
  127. </p>