Table of Contents Previous Next


6 Executing SQL Commands with executeUpdate()

In the previous example ListEmployees executed a SELECT statement using the Statement.executeQuery() method. executeQuery() was designed to execute query statements so it returns a ResultSet that contains the data returned by the query. The Statement class offers a second method that you should use to execute other types of commands (UPDATE, INSERT, DELETE, and so forth). Instead of returning a collection of rows, the executeUpdate() method returns the number of rows affected by the SQL command it executes.
The signature of the executeUpdate() method is:
Provide this method a single parameter of type String, containing the SQL command that you wish to execute.

6 Executing SQL Commands with executeUpdate()

Table of Contents Previous Next