?? 剛改purchase.jsp
字號(hào):
<%@ page import="java.sql.*,java.util.*" %>
<%@ page session="true" %>
<html>
<head>
<title>網(wǎng)上書店</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body bgcolor="#F4F5FF">
<pre>
<font face="Times New Roman,Times" size="+3"> <font color="#00FF00" face="華文彩云"><strong>網(wǎng)上書店歡迎您!</strong></font><font color="#0033FF" face="華文行楷">您的定單已經(jīng)寫入數(shù)據(jù)庫(kù)</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);
ResultSet rs=stmt.executeQuery("select * from order_info");
out.println("查看后臺(tái)") ;
while(rs.next()){
out.println("order_id:"+ rs.getString("order_id") ); out.println("customer_id:"+ rs.getString("customer_id"));
}
rs.close();
stmt.close();
connWeb.close();
}
}
catch(SQLException e)
{
e.getMessage();
}
session.putValue("shoppingcart",null);
%>
</center>
</pre>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -