wood burning stoves 2.0*
The moose likes JDBC and the fly likes execute() and executeQuery() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "execute() and executeQuery()" Watch "execute() and executeQuery()" New topic
Author

execute() and executeQuery()

deepashree deval
Greenhorn

Joined: Oct 20, 2008
Posts: 12
Can anybody tell me when shall I use the method execute() , executeQuery() what is the difference

[Updated Topic - Dave]
[ October 21, 2008: Message edited by: David O'Meara ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

one returns a ResultSet and the other does not. If you want a ResultSEt (eg from a query) then use that one.
Brian Mozhdehi
Ranch Hand

Joined: Aug 17, 2006
Posts: 81
You may also call Statement.getResultSet() if you choose to use execute() and the statement produces a ResultSet. executeQuery() is a conveience method when running SELECT statements as you of course are looking for a Result set usually in this case.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: execute() and executeQuery()
 
Similar Threads
diff bw execute and executeUpdate()
desc command in java
excute methods
Execute .executequery,executeupdate
execute query