JAVA项目之增删改查
public class ProductDao { // 查询所有商品 // BeanListHandler查询所有商品 public List<Product> getAll() throws SQLException { QueryRunner qr = new QueryRunner(MyDBUtils.getDataSource()); String sql = "select * from product" ; List <Product> arr = qr.query(sql, new BeanListHandler<Product>(Product. class )); return arr; } // 添加商品 public void add(Product product) throws SQLException { QueryRunner qr = new QueryRunner(MyDBUtils.getDataSource()); String sql = "insert into product(pid,pname,market_price,shop_price,pdate,pdesc,is_hot,cid) values(?,?,?,?,?,?,?,?)" ; Object[] obj = { product.getPid(), product