What is execute(), executeUpdate() and executeQuery()
methods?
Answer Posted / kirthi
executeQuery() --- This is used generally for reading the
content of the database. The output will be in the form of
ResultSet. Generally SELECT statement is used.
executeUpdate() --- This is generally used for altering the
databases. Generally DROP TABLE or DATABASE, INSERT into
TABLE, UPDATE TABLE, DELETE from TABLE statements will be
used in this. The output will be in the form of int. This
int value denotes the number of rows affected by the query.
execute() --- If you dont know which method to be used for
executing SQL statements, this method can be used. This
will return a boolean. TRUE indicates the result is a
ResultSet and FALSE indicates it has the int value which
denotes number of rows affected by the query.
Is This Answer Correct ? | 22 Yes | 1 No |
Post New Answer View All Answers
How to check jdbc driver version in websphere?
How can I determine where a given table is referenced via foreign keys?
Explain what should be done when a SQL exception is raised?
How the JDBC application works?
What does the jdbc connection interface?
Why do we need jdbc driver?
How can I know when I reach the last record in a table, since JDBC doesn't provide an EOF method?
How can you use preparedstatement in jdbc?
What is a jdbc driver and how many jdbc drivers are available?
What are the conditions applies to varchar variable, when using in procedures?
List the common jdbc exceptions ?
Why should we close database connections in java?
Can I use JDBC to execute non-standard features that my DBMS provides?
What is the meaning of batch updates?
What are the exceptions in jdbc?