dao方法
@Override
public void updateBook(Book book) {
String sql = "update t_book set bookname=? booktype=? where id=?";
Connection con = null;
PreparedStatement ps = null;
try {
con = DBHelper.getCon();
ps = con.prepareStatement(sql);
ps.setObject(1,book.getBookname());
ps.setObject(2,book.getPrice());
ps.setObject(3,book.getBooktype());
ps.setObject(4,book.getId());
ps.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
}finally {
DBHelper.myClose(con, ps,null);
}
}
@Override
public void delBookById(Integer id) {
String sql = "delete from t_book where id=? ";
Connection con = null;
PreparedStatement ps = null;
try {
con = DBHelper.getCon();
ps = con.prepareStatement(sql);
ps.setObject(1,id);
ps.executeUpdate();
} catch (Exception e) {
e.printStackTrace();