• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff bet execute() and executeQuery()

 
Navin Pillu
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can anybody tell me what is the difference between execute(), executeQuery()?

As per specification on sun's site

1. executeQuery is designed for statements that produce a single resultset such as SELECT statement

2. execute is used to execute statements that returns more than one result set, more than one update count, or combination of two.

Actually 2nd point i could not understand. How statements return more than one resultset. If possible give example also.

Thanks
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ability to have multiple ResultSets is dependent on features of your driver and database; not all driver/database combinations support this but many do (although a lot of people don't use this feature even when available).

Here's an example:
http://www.javaworld.com/javaworld/jw-02-2000/jw-02-ssj-jdbc2.html
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Navin Pillu:
2. execute is used to execute statements that returns more than one result set, more than one update count, or combination of two.

This is more frequent with a stored procedure returning multiple results.
 
Navin Pillu
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi stu,Jeanne

This really helped me a lot. Thanks for giving reply. Thanks to JavaWorld also.

Thanks & Regards
Navin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic