String Product_type;
String Action;
int product_id;
int curpage;
Type of product
if (Request.getparameter ("Product_type") ==null) {
Product_type= "All";
}else{
Product_type=request.getparameter ("Product_type");
}
Page number and commodity type parameters, which can be returned to the last shopping item when "continue shopping"
if (Request.getparameter ("Curpage") ==null) {
curpage=1;
}else{
Curpage=java.lang.integer.parseint (Request.getparameter ("Curpage"));
}
Shop_product.product_discount,shop_cart.cart_quantity,shop_product.product_first from Shop_cart,shop_product where shop_cart.cart_shop_id= "+ shop_id +" and shop_cart.cart_guest_id= ' "+ guest_name +" ' and shop_cart.cart_product_i D=SHOP_PRODUCT.PRODUCT_ID ";
rs = bka.executequery (SQL);
int total;
int Total_first;
total=0;
total_first=0;
String product_name;
int product_price;
int product_discount;
int Product_first;
int cart_quantity;
The program uses two tables:
1 Shop_cart Table
cart_id int Shopping Cart number Auto number
cart_shop_id nvarchar Store number
cart_product_id nvarchar Commodity number
cart_quantity int Goods Quantity
Temporary storage of shopping cart data
2 shop_product Table
product_id int Item Number Auto number
shop_id nvarchar Store number
Product_Name nvarchar Product Name
PRODUCT_BB nvarchar Product Introduction
Product_price INT Market Price
Product_discount int discount Price
product_img img Image
Product_status nvarchar State
Product_first int deposit ratio
Product_type Nvanchar Commodity Type
Store commodity Information
Javabean:bka.class made with Bka.java can provide operations on the database.
In addition, you need to register BKA.DSN in the System DSN in the Control Panel,
This allows the JSP to invoke the SQL database through JDBC-ODBC.
Calling JavaBean on a page can basically take the following ways:
<%@ page language= "java" import= "java.sql.*"%>
<jsp:usebean id= "Registerbean" scope= "page" class= "Shop.bka"/>
<%
String sql= "select * from XXX";
ResultSet rs = registerbean.executequery (SQL);
if (Rs.next ()) {
Rs.close ();
Registerbean.closestmt ();
Session.putvalue ("Register_message", "Duplicate name found!");
}
%>
Note the RS should be closed after use.
The following is the source program for Bka.java. Note that you need javac to compile the class file before use JavaBean.
--shop/bka.java--
Package shop;
Import java.sql.*;
public class Bka {
String sdbdriver = "Sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "Jdbc:odbc:bka";
Connection conn = null;
ResultSet rs = null;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.