117118119120121122123124125126127
rs.next(); // Update the id in the returned object. This is important as this value must get returned to the client. product.setProductId(rs.getInt(1)); } catch (Exception e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } return product; }
141142143144145146147148149150151
ps.setInt(6, product.getQtyInStock()); ps.setInt(7, product.getProductId()); return (ps.executeUpdate() == 1); } catch (SQLException e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } }
160161162163164165166167168169
ps.setInt(1, product.getProductId()); int count = ps.executeUpdate(); return (count == 1); } catch (Exception e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } }
2728293031323334353637
rs.getDouble("price"), rs.getInt("qty_in_stock"))); } } catch (SQLException e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } Product[] products = new Product[list.size()]; Iterator i = list.iterator();
6263646566676869707172
rs.getDouble("price"), rs.getInt("qty_in_stock"))); } } catch (SQLException e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } return list;
9293949596979899100101102
product.setPrice(rs.getDouble("price")); product.setQtyInStock(rs.getInt("qty_in_stock")); } } catch (Exception e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } return product; }
123124125126127128129130131132133
147148149150151152153154155156157
ps.setInt(6, product.getQtyInStock()); ps.setInt(7, product.getProductId()); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); } }
166167168169170171172173174175
8687888990919293949596
} } catch (SQLException e) { e.printStackTrace(); throw new DAOException(e); } finally { ConnectionHelper.close(c); }