What is the difference between executeQuery and executeUpdate in JDBC?

1 Answers
Answered by suresh

What is the difference between executeQuery and executeUpdate in JDBC?

In JDBC, the main difference between executeQuery and executeUpdate is the type of SQL statement they are designed to execute.

executeQuery: This method is used when executing SELECT statements that retrieve data from the database. It returns a ResultSet object containing the query results.

executeUpdate: On the other hand, executeUpdate is used for executing SQL statements that modify the database, such as INSERT, UPDATE, DELETE. It returns an int value representing the number of rows affected by the statement.

So, in summary, executeQuery is used for retrieving data from the database, while executeUpdate is used for modifying data within the database.

For more information on the difference between executeQuery and executeUpdate in JDBC, please refer to the official JDBC documentation or consult with a professional Java developer.

Answer for Question: What is the difference between executeQuery and executeUpdate in JDBC?