Difference between execute, executeQuery, executeUpdate

Looking for the answer for Difference between execute, executeQuery, executeUpdate . First of all i want to tell you that these are the dml statements in JDBC . The names of these statements itself explain :

executeUpdate() -> database UPDATE statements
executeQuery() -> database QUERY statements
execute() -> anything that comes in

boolean execute()
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.

ResultSet executeQuery()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.

int executeUpdate()
Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.

Leave a Reply