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

Jsp/Servlet

开发平台:

Java

  1. <%@page contentType="text/html;charset=gbk" %>
  2. <%@page import="java.sql.*" %>
  3. <%
  4. String sidbook=request.getParameter("idbook");
  5. String idbook=new String(sidbook.getBytes("iso-8859-1"));
  6. String scategoryname=request.getParameter("categoryname");
  7. String categoryname=new String(scategoryname.getBytes("iso-8859-1"));
  8. String sbookname=request.getParameter("bookname");
  9. String bookname=new String(sbookname.getBytes("iso-8859-1"));
  10. String sauthor=request.getParameter("author");
  11. String author=new String(sauthor.getBytes("iso-8859-1"));
  12. String ssuppliername=request.getParameter("suppliername");
  13. String suppliername=new String(ssuppliername.getBytes("iso-8859-1"));
  14. String soutday=request.getParameter("outday");
  15. String outday=new String(soutday.getBytes("iso-8859-1"));
  16. String sprice=request.getParameter("price");
  17. String price=new String(sprice.getBytes("iso-8859-1"));
  18. String sstock=request.getParameter("stock");
  19. String stock=new String(sstock.getBytes("iso-8859-1"));
  20. String sfabu=request.getParameter("selectfabu");
  21. String fabu=new String(sfabu.getBytes("iso-8859-1"));
  22. String shotdeal=request.getParameter("selecthotdeal");
  23. String hotdeal=new String(shotdeal.getBytes("iso-8859-1"));
  24. String ssale=request.getParameter("sale");
  25. String sale=new String(ssale.getBytes("iso-8859-1"));
  26. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  27. Connection con=DriverManager.getConnection("jdbc:odbc:booksystem");
  28. Statement sql=con.createStatement();
  29. ResultSet rs=sql.executeQuery("select * from books where idbook='"+idbook+"'");
  30. if(rs.next())
  31. out.print("此书(图书编号:'"+idbook+"')已存在于数据库中,插入失败 !"+"<p>");
  32. else
  33. {
  34. sql.executeUpdate("insert into books values('"+idbook+"','"+categoryname+"','"+bookname+"','"+author+"','"+suppliername+"','"+outday+"','"+price+"','"+stock+"','"+fabu+"','"+hotdeal+"','"+sale+"') ");
  35. out.print("<strong>已将图书(图书编号:'"+idbook+"')录入数据库!</strong>"+"<p>");
  36. }
  37.   rs=sql.executeQuery("select * from books ");
  38. out.print("数据库中的书目如下: ");
  39. out.print("<table border>");
  40. out.print("<tr>");
  41. out.print("<th width=72>图书编号</td>");
  42.     out.print("<th width=72>图书类别</td>");
  43. out.print("<th width=50>图书名称</td>");
  44. out.print("<th width=50>作者</td>");   
  45.     out.print("<th width=62>出 版 商</td>");
  46.     out.print("<th width=50>出版日期</td>");   
  47.     out.print("<th width=50>售价</td>");
  48.     out.print("<th width=50>库存(本)</td>");
  49. out.print("<th width=50>是否发布</td>");
  50. out.print("<th width=50>是否热点书</td>");   
  51.     out.print("<th width=50>出售(本)</td>");
  52. out.print("</tr>");
  53. while(rs.next())
  54. {
  55. String a,b,c,d,e,f,g,h,i,j,k;
  56. out.print("<tr>");
  57. a=rs.getString(1);
  58. out.print("<td>"+a+"</td>");
  59. b=rs.getString(2);
  60. out.print("<td>"+b+"</td>");
  61. c=rs.getString(3);
  62. out.print("<td>"+c+"</td>");
  63. d=rs.getString(4);
  64. out.print("<td>"+d+"</td>");
  65. e=rs.getString(5);
  66. out.print("<td>"+e+"</td>");
  67. f=rs.getString(6);
  68. out.print("<td>"+f+"</td>");
  69. g=rs.getString(7);
  70. out.print("<td>"+g+"</td>");
  71. h=rs.getString(8);
  72. out.print("<td>"+h+"</td>");
  73. i=rs.getString(9);
  74. out.print("<td>"+i+"</td>");
  75. j=rs.getString(10);
  76. out.print("<td>"+j+"</td>");
  77. k=rs.getString(11);
  78. out.print("<td>"+k+"</td>");
  79. out.print("</tr>");
  80. }
  81. con.close();
  82. %>