ImageVerifierCode 换一换
格式:DOCX , 页数:71 ,大小:29.50KB ,
资源ID:17103831      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-17103831.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(网上书店完整代码.docx)为本站会员(b****0)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

网上书店完整代码.docx

1、网上书店完整代码附录 全部源代码package com.shoeShop.db;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;public class Connect private static Connection con = null; private static String url=jdbc:oracle:thin:localhost:1521:ORCL; private static String driver = oracle.jdbc.driver.O

2、racleDriver; private static String user = scott; private static String pwd = tiger; public static Connection getConnection() try Class.forName(driver); con = DriverManager.getConnection(url, user, pwd); System.out.println(数据库连接成功!); catch (ClassNotFoundException e) System.out.println(驱动加载失败!); catch

3、 (SQLException e) System.out.println(数据库连接失败!); return con; public static void main(String args) Connect.getConnection(); package com.shoeShop.action;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JPanel;import com.shoeShop.view.RegisterFrame;public class d

4、ocMenuAction implements ActionListener RegisterFrame register = null; JPanel cusPanel = null; JPanel docPanel = null; public docMenuAction(RegisterFrame register) this.register = register; this.cusPanel = register.cusPanel; this.docPanel = register.docPanel; public void actionPerformed(ActionEvent e

5、) / TODO Auto-generated method stub register.flag = 1; /System.out.println(register.flag); register.remove(cusPanel); register.add(docPanel); docPanel.updateUI(); package com.shoeShop.dao;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;impo

6、rt com.shoeShop.db.Connect;import com.shoeShop.entity.Buyer;import com.shoeShop.entity.Seller;public class BuyerDao private static Connection conn; private static Statement statement; private static ResultSet resultSet; /插入数据,用于注册 public int insertBuyer(Buyer buyer) int flag = 0; conn = Connect.getC

7、onnection(); try statement = conn.createStatement(); String sql = insert into buyer values(+buyer.getId()+,+buyer.getName()+,+buyer.getPwd()+,+buyer.getAddress()+);/ System.out.println(buyer+sql); flag = statement.executeUpdate(sql); statement.close(); conn.close(); catch (SQLException e) / TODO Aut

8、o-generated catch block e.printStackTrace(); / System.out.println(flag); return flag; /通过用户名和密码查询,用于登录 public static Buyer getBuyer(String name,String pwd) conn = Connect.getConnection(); Buyer buyer = new Buyer(); try statement = conn.createStatement(); String sql = select * from buyer where buyer_

9、id=+name+ and pwd = +pwd+; resultSet = statement.executeQuery(sql); while(resultSet.next() buyer.setId(resultSet.getString(buyer_id); buyer.setName(resultSet.getString(buyer_name); buyer.setPwd(resultSet.getString(pwd); buyer.setAddress(resultSet.getString(address); resultSet.close(); statement.clos

10、e(); conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); return buyer; public static void main(String args) BuyerDao dao = new BuyerDao(); System.out.println(dao.getBuyer(zxk, 654321);/ Buyer buyer = new Buyer();/ buyer.setId(lily);/ buyer.setName(长理专卖);/ buye

11、r.setPwd(123456);/ buyer.setAddress(湖南长沙);/ dao.insertBuyer(buyer); package com.shoeShop.dao;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;import com.shoeShop.db.Connect;import com.shoeShop.entity.Goods;import c

12、om.shoeShop.entity.Seller;import com.shoeShop.imp.User;public class GoodsDao private static Connection conn; private static Statement statement; private static ResultSet resultSet; /查询登录商家的所有商品,用于商家管理自己的商品 public ArrayList getAllGoods() ArrayList list = new ArrayList(); conn = Connect.getConnection(

13、); try statement = conn.createStatement(); String sql = select * from goods a,seller b where a.seller_id=b.seller_id and b.seller_id=+User.getUserName()+; resultSet = statement.executeQuery(sql); while(resultSet.next() Seller seller = new Seller(); seller.setName(resultSet.getString(seller_name); se

14、ller.setAddress(resultSet.getString(address); Goods goods = new Goods(); goods.setSeller(seller); goods.setId(resultSet.getInt(goods_id); goods.setName(resultSet.getString(goods_name); goods.setSeller_id(resultSet.getString(seller_id); goods.setDiscount(resultSet.getInt(discount); goods.setNum(resul

15、tSet.getInt(num); goods.setPrice(resultSet.getInt(price); / System.out.println(goods.toString(); list.add(goods); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally try resultSet.close(); statement.close(); conn.close(); catch (SQLException e) / TODO Auto-generated

16、 catch block e.printStackTrace(); return list; /查询所有商家的所有商品.用于用户搜索商品 public ArrayList getAllSellerGoods() ArrayList list = new ArrayList(); conn = Connect.getConnection(); try statement = conn.createStatement(); String sql = select * from goods a,seller b where a.seller_id=b.seller_id; resultSet = s

17、tatement.executeQuery(sql); while(resultSet.next() Seller seller = new Seller(); seller.setName(resultSet.getString(seller_name); seller.setAddress(resultSet.getString(address); Goods goods = new Goods(); goods.setSeller(seller); goods.setId(resultSet.getInt(goods_id); goods.setName(resultSet.getStr

18、ing(goods_name); goods.setSeller_id(resultSet.getString(seller_id); goods.setDiscount(resultSet.getInt(discount); goods.setNum(resultSet.getInt(num); goods.setPrice(resultSet.getInt(price); / System.out.println(goods.toString(); list.add(goods); catch (SQLException e) / TODO Auto-generated catch blo

19、ck e.printStackTrace(); finally try resultSet.close(); statement.close(); conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); return list; /根据商品号查询商品信息 public Goods getOneGoods(int id) Goods goods = new Goods(); conn = Connect.getConnection(); try statement =

20、conn.createStatement(); String sql = select * from goods where goods_id = +id; resultSet = statement.executeQuery(sql); while(resultSet.next() goods.setId(id); goods.setName(resultSet.getString(goods_name); goods.setPrice(resultSet.getInt(price); goods.setNum(resultSet.getInt(num); goods.setDiscount

21、(resultSet.getInt(discount); goods.setSeller_id(resultSet.getString(seller_id); goods.setNum(resultSet.getInt(num); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally try resultSet.close(); statement.close(); conn.close(); catch (SQLException e) / TODO Auto-generat

22、ed catch block e.printStackTrace(); return goods; /修改商品信息 public int updateGoods(Goods goods) int flag = 0; conn = Connect.getConnection(); try statement = conn.createStatement(); String sql = update goods set goods_name=+goods.getName()+,price =+goods.getPrice() +,discount =+goods.getDiscount()+,nu

23、m=+goods.getNum()+ where goods_id=+goods.getId(); flag = statement.executeUpdate(sql); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally try statement.close(); conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); return flag;

24、 /通过id删除商品 public int deleteById(int id) int flag = 0; conn = Connect.getConnection(); try statement = conn.createStatement(); String sql = delete goods where goods_id = +id; flag = statement.executeUpdate(sql); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally tr

25、y statement.close(); conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); return flag; /添加 public int insertGoods(Goods goods) int flag = 0; conn = Connect.getConnection(); try statement = conn.createStatement(); String sql = insert into goods values(select max

26、(goods_id+1) from goods),+User.getUserName()+,+goods.getName()+,+goods.getPrice()+,+goods.getDiscount()+,+goods.getNum()+); flag = statement.executeUpdate(sql); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally try statement.close(); conn.close(); catch (SQLExcept

27、ion e) / TODO Auto-generated catch block e.printStackTrace(); return flag; public static void main(String args) GoodsDao dao = new GoodsDao();/ Goods goods = new Goods();/ goods.setName(c+);/ goods.setPrice(50);/ User.setUserName(niclascage);/ goods.setDiscount(8);/ goods.setNum(10);/ System.out.pri

28、ntln(main);/ System.out.println(ii+dao.insertGoods(goods);/ System.out.println(dao.deleteById(4);/ Goods goods = new Goods();/ goods.setId(1);/ goods.setName(oracle);/ goods.setPrice(50);/ goods.setDiscount(8);/ goods.setNum(5);/ System.out.println(dao.updateGoods(goods); dao.getAllSellerGoods();/ Syst

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2