📄 shoppingcart.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -