Page 22 - Abstract Class, Interface & Struktur Data
P. 22
Update
Berikut potongan syntax update
Connection conDB = ConnectionDB.getConnection();
String sql = "UPDATE product_hp SET productCategory =?,
productName=?, price=?, qty=? WHERE productId=?";
PreparedStatement ps = conDB.prepareStatement(sql);
ps.setString(1, product.getProductCategory());
ps.setString(2, product.getProductName());
ps.setDouble(3, product.getPrice());
ps.setInt(4, product.getQty());
ps.setInt(5, product.getProductId());
ps.executeUpdate();