• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused about JDBC RowSets  RSS feed

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still learning here ...

I have my little app's first form/screen working with a ResultSet from my database. After running into some limitations, my research yielded that perhaps I should be using RowSets instead. The issue seems to be that all the implementation classes are part of Sun libraries that I'm warned not to use in an application because it is an "internal proprietary API and may be removed in a future release".

Every example I see uses these. In fact, some point out the warning, and then tell you how to do it? I'm confused ... it's like it's saying "here's how to use RowSets, and by the way, don't use RowSets." Please help - if I want to use RowSets, is there some "correct" way to do it that is different than these examples? How do I create RowSet instances w/o using those Sun libraries?

TIA!
 
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I see is this: everything in the standard API relating to RowSet is an interface which has to be implemented by some code which isn't part of the API. That's just like JDBC. And to get that code you call RowSetProvider.getFactory(), which gives you a RowSetFactory. This may be a factory which you got from somewhere else and put in your classpath, or it may be one hidden inside the standard API. You don't need to use internal java classes, at least you don't need to import them and use them explicitly.

But I saw this by reading the standard API docs and it says those things were added in Java 7. Chances are you're reading tutorials which are older than that -- remember, nothing ever dies on the web and there's tons of outdated information there.

And speaking of the web, when I searched for RowSet implementations I couldn't find any links to people who had actually written one and wanted you to use it. Perhaps there's no market for that, or perhaps people have only been writing them as parts of larger projects, I don't know.

But you might want to try addressing the "limitations" you found in some other way. Would you like to ask that question here?
 
Ken Matson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

But you might want to try addressing the "limitations" you found in some other way. Would you like to ask that question here?



Hi thanks! Well - the specific limitation I was trying to overcome is a way to "revert" a row in my ResultSet back to it's original values w/o having to go back to the database. I don't see a way in a ResultSet , but a RowSet seems to support this?

also - the idea of being able to use a RowSet in disconnected mode and only reconnect when time to update the back-end seems like a positive for my situation that a ResultSet can't really do?

thanks!
 
Paul Clapham
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked in the docs for RowSet but I didn't see anything like "revert" right away, but there's a million methods and maybe I missed it.

Anyway based on the API documentation for RowSetProvider it looks to me like you just need



RowSetProvider and RowSetFactory appear to be new in Java 7, but unfortunately the documentation for earlier classes like CachedRowSet hasn't been updated to reflect that. At least that's my guess. Maybe you could try those two rows of code to start with and see what you can do with that CachedRowSet?
 
Paul Clapham
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, after I read the API docs, I found out that Oracle's RowSet tutorial tells you to do exactly what I suggested. It doesn't mention com.sun classes at all.

(I always by preference read the Oracle tutorials before anybody else's tutorial.)
 
Ken Matson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Actually, after I read the API docs, I found out that Oracle's RowSet tutorial tells you to do exactly what I suggested. It doesn't mention com.sun classes at all.

(I always by preference read the Oracle tutorials before anybody else's tutorial.)




isn't JdbcRowSetImpl  from the sun library?
 
Paul Clapham
Sheriff
Posts: 23451
46
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scroll down to the bit headed "Using the RowSetFactory Interface".
 
Ken Matson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have to check out next week - gonna be out for several days here ... THANKS!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!