• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating RowSet with another RowSet

 
Seb Castiaux
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working on a client/server querying application. I want to keep the entire result of query on the server and send blocks of this result to the client on demand.
Let's consider a RowSet (serverRS) of 100 elements and I want to send rows 21 to 40 to the client.
How can I populate a RowSet (clientRS) with those rows? Eliminating the first rows seems easy by calling serverRS.absolute(21) before calling clientRS.populate(serverRS) but I cannot find an easy way for the rows after row 40?
Can u help me?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you querying a database on the server? Or are you querying your own server implementation of some sort. Basically, I am not sure this question is about and belongs in the JDBC forum. If you could clarify what you are doing I may be able to find a better forum for this question or I will leave it here.
 
Seb Castiaux
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am querying a database on the server and cache the obtained ResultSet. I would like to send this data to my client by blocks (on demand) as RowSet. My problem is to extract the block from the cached ResultSet and put it in the serializable RowSet that i send to the client.
Don't hesitate to ask for some clarifications if i am not making myself clear.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you need to do is scrap the ResultSet all together and use the RowSet API in the JDBC spec. I am still not entirely clear on what you are trying to do. But to me it looks like you have an extra step.
Query the Database
Put data in RowSet
Send chucks of that RowSet to a client
So if this is accurate, I would ask why not allow the client to query the database and return what it needs?
BTW - Here is a tutorial on using the JDBC RowSet API (CachedRowSet, JDBCRowSet, WebRowSet). If I am way off track let me know.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is the scenario that we are describing:
1) We extract data from a database and store the result in a CachedRowSet.
2) We want to send part of this RowSet to a client as a new RowSet object.
There may be several reasons that the client can not access the database directly. It could be a firewall issue or simply a size issue.
The question is, can I create a new RowSet from the middle of an existing RowSet.
I don't see any straight forward way to do this from the documentation. In fact, although using absolute(21) works, since this is not documented I would be nervous about relying on it. It just happens that the implementation does not reset the ResultSet to the beginning but I see nothing that would make me think that this is guaranteed in all implementations.
You could create a new RowSet using populate() and then delete the unwanted rows. Or you could create a new empty RowSet, copy the MetaData over, and then insert rows. Neither is a very pretty solution.
Perhaps the easiest way would be to write your own implementation, extending CachedRowSetImpl.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, if Tom is correct in his assumptions of the problem, it makes sense now. Thanks for clearing that up. I would be interested in learning how you decided to solve this problem Seb.
 
Seb Castiaux
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clarifications Tom, your assumptions are totaly right. The reason is only a size and network traffic problem. I will let you know how I manage to solve this problem.
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic