📄 book.java
字号:
package jspcart.books;import java.util.*;import jspcart.conn.*;import java.sql.*;public class Book { private String bname; private float price; private int bnum; private int ID; public Book() { } public Book(int id,String name,float price,int num){ this.setID(id); this.setBname(name); this.setPrice(price); this.setBnum(num); } public int getID() { return ID; } public void setID(int ID) { this.ID = ID; } public String getBname() { return bname; } public void setBname(String bname) { this.bname = bname; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public int getBnum() { return bnum; } public void setBnum(int bnum) { this.bnum = bnum; } //获取所有货物 public List getBooks(DBConnection db){ List l=new ArrayList(); String sql="select * from product"; ResultSet rst=null; rst=db.Execsql(sql); try { while(rst.next()){ int bid=rst.getInt(1); String bname=rst.getString(2); float bprice=rst.getFloat(3); int bnum=rst.getInt(4); Book book=new Book(bid,bname,bprice,bnum); l.add(book); } } catch (Exception ex) { ex.printStackTrace(); } return l; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -