publicvoiddelOrderItem(String id) {// TODO 自动生成的方法存根String sql="delete from orderitem where order_id = ?";try {QueryRunner runner = new QueryRunner(DaoUtils .getSource());runner.update(sql,id);} catch (Exception e) {// TODO: handle exceptione.printStackTrace();thrownew RuntimeException(e);}}
更新修改数据
publicvoidupdateState(int id) {// TODO 自动生成的方法存根String sql = "update users set state = 1 where id=?";try{QueryRunner runner = new QueryRunner(DaoUtils .getSource());runner.update(sql,id);}catch (Exception e) {e.printStackTrace();thrownew RuntimeException(e);} }
public Order findOrderById(String p2_Order) {// TODO 自动生成的方法存根String sql = "select * from orders where id = ?";try{QueryRunner runner = new QueryRunner(DaoUtils .getSource());return runner.query(sql, new BeanHandler<Order>(Order.class),p2_Order);}catch (Exception e) {e.printStackTrace();thrownew RuntimeException(e);}}
BeanListHandler
public List<SaleInfo> saleList() {// TODO 自动生成的方法存根String sql = " select products.id prod_id,products.name prod_name,sum(orderitem.buynum ) sale_num"+" from orders ,orderitem ,products "+" where "+" orders.id=orderitem.order_id "+" and "+" orderitem.product_id=products.id"+" and orders.paystate = 1"+" group by products.id"+" order by sale_num desc";try{QueryRunner runner = new QueryRunner(DaoUtils .getSource());return runner.query(sql, new BeanListHandler<SaleInfo>(SaleInfo.class));}catch (Exception e) {e.printStackTrace();thrownew RuntimeException(e);}}