Executing PreparedStatement Objects
by, 03-10-2012 at 09:03 AM (1310 Views)
- Execute statement shall be called for execution of a PreparedStatement Object.
- The executeQuery when just 1 ResultSet is returned by query,
- The executeUpdate when no ResultSet is returned by query.
- The execute when one or more than one ResultSet object return by query.
Call of “execute update” method is explained by this code.
To executeUpdate, arguments are not supplied while their usage to execute updateTotals or updateSales. SQL statements are present in both PreparedStatement objects to get executed.Java Code:updateSales.setInt(1, e.getValue().intValue()); updateSales.setString(2, e.getKey()); updateSales.executeUpdate(); updateTotal.setInt(1, e.getValue().intValue()); updateTotal.setString(2, e.getKey()); updateTotal.executeUpdate(); con.commit();