jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes RowSet over ResultSet - Need explanation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "RowSet over ResultSet - Need explanation" Watch "RowSet over ResultSet - Need explanation" New topic

RowSet over ResultSet - Need explanation

Debs Chatterjee

Joined: Jun 13, 2012
Posts: 2
Hi All,

I was reading through RowSet Objects in JDBC Tutorial & found that it is written as
Some DBMSs do not support result sets that can be scrolled (scrollable), and some do not support result sets that can be updated (updatable). If a driver for that DBMS does not add the ability to scroll or update result sets, you can use a RowSet object to do it.
So that means if we use RowSet Object, by default it is scrollable & updatable. But there is another statement written in
Using JDBCRowSet Objects
topic that -
A JdbcRowSet object created with a ResultSet object serves as a wrapper for the ResultSet object. Because the RowSet object rs is scrollable and updatable, jdbcRs is also scrollable and updatable. If you have run the method createStatement without any arguments, rs would not be scrollable or updatable, and neither would jdbcRs.

So now I am confused, in the above case RowSet is dependent on resultSet type. Then if some DBMS drive does not support scrollable RowSet object it will also not support jdbcRowSet object which is constructed like above. Can someone explain me this? Also can somebody tell me some example of DBMS which does not support scrollable resultSet ? What is actual usage of RowSet over ResultSet ?
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

I don't have experience using RowSets, so I may be wrong, but I believe that if you want to ensure the updatability and scrollability regardless of the database capabilities, you need to use Default JdbcRowSet Objects, as described in that tutorial.

If you create the RowSet from an existing ResultSet, it won't add the special capabilities (I believe the fundamental reason is it is not possible to obtain the SQL query the resultset is based on).
Malcolm Clews

Joined: Aug 30, 2007
Posts: 19
Hello All,

My interpretation of the documentation was the same as Debs I think, but if I understand Martin correctly, then this would explain why trying to get scrollability (don't need updatability) from the results returned from an Oracle stored procedure won't work, because the Oracle CURSOR is 'forward only':-

Am I right about the CURSOR being at the root of the problem?

Can anyone offer any ideas for 'converting' the CURSOR to a scrollable resultSet?

Of course I can write some code to iterate through the resultSet and process it, but ideally I just want that resultSet scrollable. The code is from an application that queries sundry database sources by means of prepared statements, and then processes the results with a lot of proven, tried and tested code dependent upon scrollable resultSets. For various reasons it makes sense to use Oracle stored procedures for this datasource, I'll be able to reuse lots of code and integrate more easily if the data is scrollable.

Thanks for taking the time to read this far, any ideas and suggestions welcome
I agree. Here's the link: http://aspose.com/file-tools
subject: RowSet over ResultSet - Need explanation
It's not a secret anymore!