• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

IBM 484 : Stmt.execute(Str) - multiple result sets?

 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is another question in the trial whizlabls J2EE 484 simulator which I would like to discuss it here.
Moderator(s): In case there are any copyright issues, please feel free to delete this post.
1. You are executing a stored procedure that may return multiple results. Which of the following JDBC methods and interfaces will you use for the purpose?
A. execute() method and CallableStatement interface
B. execute() method and PreparedStatement interface
C. executeQuery() method and CallableStatement interface
D. executeQuery() method and PreparedStatement interface
E. executeUpdate() method and Statement interface
F. executeUpdate() method and PreparedStatement interface
Correct Answer : A
I checked up the API also, option A is the correct answer.
Statement
^
|
PreparedStatement
^
|
CallableStatement
I found the foll. in the JDK1.4 API docs:


public boolean execute(String sql)throws SQLException
- Executes the given SQL statement, which may return multiple results. In some (uncommon) situations, a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.
The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).


But what are multiple result sets? ...I am familiar with a single Result Set. Most of the times, I have used executeQuery() to execute Select statements returning multiple rows and also stored procedures returning a value. Can somebody give me an example of multiple result sets?
[ May 06, 2004: Message edited by: Vishwa Kumba ]
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out this article
http://www-106.ibm.com/developerworks/java/library/j-jw-jdbc2/
Hope this helps.
Best Wishes,
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Seema,
That is a good article about the multiple result sets...
 
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice informative article.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic