executeQuery(), executeUpdate() and execute() are the methods of java.sql.Statement interface of JDBC API which are used to execute the SQL statements.
executeQuery() Vs executeUpdate() Vs execute()
executeQuery() | executeUpdate() | execute() |
This method is use to execute the SQL statements which retrieve some data from database. | This statement is used to execute SQL statements which update or modify database. | This method can be use for any kind of SQL statements. |
This method returns a ResultSet object which contains the result returned by query. | This method returns an int value which represent number of rows affected by the query. This will be 0 for statement which are returning nothing. | This method return a Boolean value. TRUE indicates that query returned a ResultSet object and FALSE indicate returned an int value or returned nothing. |
This method is use to execute select query. | This method is use to execute non select query. | This method is use to execute select and non select queries. |
Ex: SELECT | Ex: DML->INSERT , UPDATE and DELETEDDL-> CREATE, ALTER |
Any Type of SQL statements. |
More on JDBC
Follow below links to know more on JDBC and solving JDBC issues :
You must log in to post a comment.