Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Vishwa Kumba
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 ]
 
Seema Manivannan
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...
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice informative article.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic