原来purchase.jsp
上传用户:sanhemotor
上传日期:2010-01-25
资源大小:381k
文件大小:1k
- <%@ page import="java.sql.*,java.util.*" %>
- <%@ page session="true" %>
- <html>
- <head>
- <title>网上书店</title>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
- <body bgcolor="#F4F5FF">
- <font face="Times New Roman,Times" size="+3"> <font color="#00FF00" face="华文彩云"><strong>网上书店欢迎您!</strong></font><font color="#0033FF" face="华文行楷">您的定单已经写入数据库</font></font>
- <font color="#0033FF" face="华文行楷">!</font>
- <hr><p>
- <center>
- <%
- int customer_id;
- String cID=(String)session.getValue("cID");
- customer_id=Integer.parseInt(cID);
-
- Vector buyList=(Vector)session.getValue("shoppingcart");
- try
- {String sDBDriver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
- Class.forName(sDBDriver);
- String sConnStr="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Web";
- String username="sa";
- String password="";
- Connection connWeb=DriverManager.getConnection(sConnStr,username,password);
- Statement stmt=connWeb.createStatement();
- for(int i=0;i<buyList.size();i++)
- {
- int bookid=((shop.Bookinfo)buyList.elementAt(i)).getId();
- int book_quantity=((shop.Bookinfo)buyList.elementAt(i)).getQuantity();
- String query="insert into order_info(Customer_ID,Book_ID,Book_Quantity) values('"+cID+"','"+bookid+"','"+book_quantity+"')";
- stmt.executeUpdate(query);
- stmt.close();
- connWeb.close();
- }
- }
- catch(SQLException e)
- {
- e.getMessage();
- }
- session.putValue("shoppingcart",null);
- %>
- </center>
- </body>
- </html>