• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ResultSet wrapped in a JdbcRowSet

 
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody,

For the exam is very important indeed understanding that any RowSet is also a wrapper for ResultSet otherwise not scrollable or updatable.

What about this line in this java tutorial?

Note: The ResultSet object that is passed to the JdbcRowSetImpl constructor must be scrollable.



If any RowSet automatically by wrapping a ResultSet adds the scrollability and updatability, why the ResultSet passed to the JdbcRowSetImpl must be scrollable? Where is the sense in that?

Furthermore in the same tutorial they totally contradict themselves:

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.


Which clearly contradicts the fact that a JdbcRowSet serves as a wrapper for resultset otherwise non scrollable and non updatable..

What do you think about that?

Hoping they are not playing with these things on the exam.

Thanks in advance.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well ResultSet by default is not scrollable and update-able. But it can be made these things, if you see the java.sql.ResultSet you'll find

A default ResultSet object is not updatable and has a cursor that moves forward only. Thus, you can iterate through it only once and only from the first row to the last row. It is possible to produce ResultSet objects that are scrollable and/or updatable. The following code fragment, in which con is a valid Connection object, illustrates how to make a result set that is scrollable and insensitive to updates by others, and that is updatable. See ResultSet fields for other options.


The tutorial is kind of misguiding I would say. I can't say if they play with such things on the exam. We have authors of new SCJP 7 book this week they may have more knowledge about it...
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I went through the documentation of JdbcRowSet, and what it's intended to do is it makes any ResultSet scrollable and update-able. Not all databases and JDBC drivers are scrollable. But irrespective of whether your ResultSet is scrollable and update-able, JdbcRowSet will add those capabilities...
 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:I went through the documentation of JdbcRowSet, and what it's intended to do is it makes any ResultSet scrollable and update-able. Not all databases and JDBC drivers are scrollable. But irrespective of whether your ResultSet is scrollable and update-able, JdbcRowSet will add those capabilities...



Thanks or replying,
However if you create a JdbcRowSet by passing a ResultSet in the constructor as JdbcRowSet rowSet = new JdbcRowSetImpl(rs); and the rs is not updatable, the outcome of the wrapped jRowSet is not updatadable.
Yet they say that it allows any result set to be updatable and scrollable... It's kind of confusing.

Again from the same tutorial:


One of the main uses of a JdbcRowSet object is to make a ResultSet object scrollable and updatable when it does not otherwise have those capabilities.



after a few lines below they contradicts what they have just said:


Note: The ResultSet object that is passed to the JdbcRowSetImpl constructor must be scrollable.



I would add it must be updatable too as if I pass a ResultSet in the JdbcResultSetImpl(rs); construcctor If this ResultSet I am passing is not updatable, the RowSet won't be
updatable.
I am quite concerned for the exam about this topic as both the java tutorial and the mock exams I have done so far, are quite ramming a point of the fact that any RowSet will make scrollable and updatable any ResultSet otherwise not having those capabilities. And when of course i select the answer stating they are wrappers giving scrollability and updatability it's the right answer for the mocks. But still... passing a ResultSet in the constructor which is non scrollable and non updatable it will not produce the expected outcome, plus the contradiction in the java tutorial.

At this point I might thing that what they mean is: It is a wrapper for any ResultSet otherwise not scrollable or updatable, however when this ResultSet is created it must be declared with those parameters on. (ResultSet.CONCUR_UPDATABLE, ResultSet.TYPE_SCROLL_INSENSITIVE); now if the database and the drivers or either of them don't support those capabilities the JdbcRowSet will make up for it. But if those parameters are not set, even if wrapped in a JdbcRowSet the result will be the same (non scrollable non updatable).

It is my view of the thing. I cannot think of anything else... I am using mysql and those are supported capabilities, so I cannot test what happens with an underlying dbms/drivers not supporting them.

Anybody feeling to confirm (or not) my thesis, please do it as this topic is quite bleak.

Thanks in advance.

 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic