This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

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

 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
Nice informative article.
 
No holds barred. And no bars holed. Except this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!