What is the difference between executeQuery() and executeUpdate() methods in JDBC?

1 Answers
Answered by suresh

Understanding the Difference between executeQuery() and executeUpdate() in JDBC

What is the difference between executeQuery() and executeUpdate() methods in JDBC?

In JDBC, the executeQuery() method is used to execute SQL SELECT statements that return a ResultSet object containing the query results. On the other hand, the executeUpdate() method is used to execute SQL statements such as INSERT, UPDATE, DELETE, and DDL statements, and it returns the number of rows affected.

Therefore, the key difference between executeQuery() and executeUpdate() methods in JDBC is that executeQuery() is used for querying and retrieving data, while executeUpdate() is used for modifying data in the database.

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