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


Please Help Members By Posting Answers For Below Questions

How to check jdbc driver version in websphere?

543


How can I determine where a given table is referenced via foreign keys?

551


Explain what should be done when a SQL exception is raised?

548


How the JDBC application works?

528


What does the jdbc connection interface?

534






Why do we need jdbc driver?

474


How can I know when I reach the last record in a table, since JDBC doesn't provide an EOF method?

585


How can you use preparedstatement in jdbc?

514


What is a jdbc driver and how many jdbc drivers are available?

580


What are the conditions applies to varchar variable, when using in procedures?

1612


List the common jdbc exceptions ?

563


Why should we close database connections in java?

683


Can I use JDBC to execute non-standard features that my DBMS provides?

553


What is the meaning of batch updates?

556


What are the exceptions in jdbc?

497