Answer & Solution
Answer: Option C
Solution:
executeUpdate(): This method is used to execute SQL statements that update the database, such as
INSERT,
UPDATE, or
DELETE statements. It returns an integer representing the number of rows affected by the query.
execute(): This method can be used to execute any SQL statement, and it returns a boolean. The returned value is
true if the result is a
ResultSet object; otherwise, it returns
false.
executeBatch(): This method is used to execute a batch of SQL statements. It sends multiple SQL statements to the database for execution as a batch and returns an array of update counts. It is not used to execute a single SQL query.
executeQuery(): This method is used to execute SQL queries that retrieve data from the database, such as
SELECT statements. It returns a
ResultSet object containing the data produced by the query.
Therefore,
executeBatch() is not a valid method to execute a single SQL query in JDBC.