Question about Statement object

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
The_Nick
Posts: 132
Joined: Thu May 16, 2013 9:23 am
Contact:

Question about Statement object

Post by The_Nick »

Hi, I have a question related to this method: st.execute(sql); where st obviously is a Statement object.
Directly from docs.oracle.com/javase/tutorial/jdbc/ba ... ng_queries
execute: Returns true if the first object that the query returns is a ResultSet object. Use this method if the query could return one or more ResultSet objects. Retrieve the ResultSet objects returned from the query by repeatedly calling Statement.getResutSet.
What do they mean by "one or more ResultSet objcets"? if so how is it possible to manage them once got an array of ResultSet?
Whereas st.executeQuery(sql) and st.exectureUpdate(sql) are very clear. It's not (at least to me) the aim of st.execute(sql) which can also return an int as if it was updated a table.

Thanks in advance..
The_Nick.

Online
admin
Site Admin
Posts: 10065
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Question about Statement object

Post by admin »

What you are asking is explained in the text that you've quoted. After executing the query (which could even be a stored procedure) You can call Statement.getResutSet again and again to get the result sets returned by the query until you get null.

st.execute() doesn't return int. As you've quoted, it returns a boolean.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 210 guests