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 achieve JDBC Connection Pooling using JDBC DataSource and JNDI in Apache Tomcat Server?
How can we set null value in jdbc preparedstatement?
How do I receive a ResultSet from a stored procedure?
What is resultset in jdbc with example?
How to test jdbc connection to sql server?
What is difference between java.util.Date and java.sql.Date?
Why would you use setautocommit(false) in jdbc?
Name the types of jdbc drivers.
How the JDBC application works?
What does executeupdate return in jdbc?
What is JDBC Statement?
What is meant by dao?
What is metadata in programming?
What is jdbc url for mysql?
What are the differences between stored procedure and functions?