writenewbook_result.jsp
上传用户:cnkaiguan
上传日期:2014-08-25
资源大小:5403k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- <%@page contentType="text/html;charset=gbk" %>
- <%@page import="java.sql.*" %>
- <%
- String sidbook=request.getParameter("idbook");
- String idbook=new String(sidbook.getBytes("iso-8859-1"));
- String scategoryname=request.getParameter("categoryname");
- String categoryname=new String(scategoryname.getBytes("iso-8859-1"));
- String sbookname=request.getParameter("bookname");
- String bookname=new String(sbookname.getBytes("iso-8859-1"));
- String sauthor=request.getParameter("author");
- String author=new String(sauthor.getBytes("iso-8859-1"));
- String ssuppliername=request.getParameter("suppliername");
- String suppliername=new String(ssuppliername.getBytes("iso-8859-1"));
- String soutday=request.getParameter("outday");
- String outday=new String(soutday.getBytes("iso-8859-1"));
- String sprice=request.getParameter("price");
- String price=new String(sprice.getBytes("iso-8859-1"));
- String sstock=request.getParameter("stock");
- String stock=new String(sstock.getBytes("iso-8859-1"));
- String sfabu=request.getParameter("selectfabu");
- String fabu=new String(sfabu.getBytes("iso-8859-1"));
- String shotdeal=request.getParameter("selecthotdeal");
- String hotdeal=new String(shotdeal.getBytes("iso-8859-1"));
- String ssale=request.getParameter("sale");
- String sale=new String(ssale.getBytes("iso-8859-1"));
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- Connection con=DriverManager.getConnection("jdbc:odbc:booksystem");
- Statement sql=con.createStatement();
- ResultSet rs=sql.executeQuery("select * from books where idbook='"+idbook+"'");
- if(rs.next())
- out.print("此书(图书编号:'"+idbook+"')已存在于数据库中,插入失败 !"+"<p>");
- else
- {
- sql.executeUpdate("insert into books values('"+idbook+"','"+categoryname+"','"+bookname+"','"+author+"','"+suppliername+"','"+outday+"','"+price+"','"+stock+"','"+fabu+"','"+hotdeal+"','"+sale+"') ");
- out.print("<strong>已将图书(图书编号:'"+idbook+"')录入数据库!</strong>"+"<p>");
- }
- rs=sql.executeQuery("select * from books ");
- out.print("数据库中的书目如下: ");
- out.print("<table border>");
- out.print("<tr>");
- out.print("<th width=72>图书编号</td>");
- out.print("<th width=72>图书类别</td>");
- out.print("<th width=50>图书名称</td>");
- out.print("<th width=50>作者</td>");
- out.print("<th width=62>出 版 商</td>");
- out.print("<th width=50>出版日期</td>");
- out.print("<th width=50>售价</td>");
- out.print("<th width=50>库存(本)</td>");
- out.print("<th width=50>是否发布</td>");
- out.print("<th width=50>是否热点书</td>");
- out.print("<th width=50>出售(本)</td>");
- out.print("</tr>");
- while(rs.next())
- {
- String a,b,c,d,e,f,g,h,i,j,k;
- out.print("<tr>");
- a=rs.getString(1);
- out.print("<td>"+a+"</td>");
- b=rs.getString(2);
- out.print("<td>"+b+"</td>");
- c=rs.getString(3);
- out.print("<td>"+c+"</td>");
- d=rs.getString(4);
- out.print("<td>"+d+"</td>");
- e=rs.getString(5);
- out.print("<td>"+e+"</td>");
- f=rs.getString(6);
- out.print("<td>"+f+"</td>");
- g=rs.getString(7);
- out.print("<td>"+g+"</td>");
- h=rs.getString(8);
- out.print("<td>"+h+"</td>");
- i=rs.getString(9);
- out.print("<td>"+i+"</td>");
- j=rs.getString(10);
- out.print("<td>"+j+"</td>");
- k=rs.getString(11);
- out.print("<td>"+k+"</td>");
- out.print("</tr>");
- }
- con.close();
- %>