code: public static int update(Connection con, String query, Object... param) throws SQLException {
      PreparedStatement stmt = null;
      try {
        stmt = con.prepareStatement(query);
        for (int i = 0; i < param.length; i++) {
          stmt.setObject(i + 1, param[i]);
        }
        return stmt.executeUpdate();
      } finally {
        close(stmt);
      }
    }
docs: Runs a SQL query that inserts, updates, or deletes rows.
  @param con The <code>Connection</code> against which to run the query.
  @param query The SQL query to run.
  @param param The parameters to the SQL query.
  @return The number of rows affected by the query.
  @throws SQLException If an error occurs while attempting to communicate
  with the database.