aspose file tools*
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 Soft Skills this week in the Jobs Discussion 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: execute() and executeQuery()