Page 1 of 1

Question about Statement object

Posted: Sat May 18, 2013 6:22 am
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.

Re: Question about Statement object

Posted: Mon May 20, 2013 5:40 pm
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.