shoppingcart.java
来自「电子商务系统: 项目描述:该系统主要完成用户网上购物、订单管理、产品管理、管理」· Java 代码 · 共 53 行
JAVA
53 行
package com.tarena.shop.biz;import java.sql.*;import java.util.*;import com.tarena.shop.biz.dao.ShoppingCartDao;import com.tarena.shop.entity.Order;import com.tarena.shop.entity.Product;import com.tarena.shop.entity.User;import com.tarena.shop.entity.dao.hbn.UserDaoHbn;import com.tarena.shop.util.ConnectionFactory;public class ShoppingCart implements ShoppingCartDao{ public int generateOrder(Order order) { return 0; } public Collection listProducts() { Collection coll=new ArrayList(); Connection con = ConnectionFactory.getConnection(); String sql=null; try{ sql="select * from productxp"; Statement st = con.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet rs=st.executeQuery(sql); while(rs.next()){ Product p = new Product(); p.setId(rs.getInt("productid")); p.setName(rs.getString("name")); p.setPrice(rs.getDouble("price")); p.setDescription(rs.getString("description")); coll.add(p); } }catch(SQLException e){ e.printStackTrace(); } return coll; } public User login(String username, String password) { User u = new User(); u.setUserName(username); u.setPassword(password); UserDaoHbn udh= new UserDaoHbn(); User newuser=udh.selectByUser(u); System.out.println(newuser+"++"); return newuser; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?