aspose file tools*
The moose likes JDBC and the fly likes Can i get a clone of Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can i get a clone of Resultset" Watch "Can i get a clone of Resultset" New topic
Author

Can i get a clone of Resultset

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
I am having resultsets obtained from execution of query on two different database connections. i want to work on the two result sets simultaneously.
My current condition is the first connection is closed before the execution of the second query. Is there any way where i can store the first resultset without having attachment to any connection?? or can i create a clone for the resultset.

clone method over the object class is having protected access and i am wondering how to proceed.

regards,
Surendar prabu


SCJP 1.4
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

The resultset data is really just an array of HashMaps. Just build a set of HashMap out of the data and store it in memory.


My Blog: Down Home Country Coding with Scott Selikoff
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by surendar prabu:
Is there any way where i can store the first resultset without having attachment to any connection?? or can i create a clone for the resultset.



I think CachedRowSet is the answer for you.

As per javadocs


A CachedRowSet object is a container for rows of data that caches its rows in memory, which makes it possible to operate without always being connected to its data source. Further, it is a JavaBeansTM component and is scrollable, updatable, and serializable. A CachedRowSet object typically contains rows from a result set, but it can also contain rows from any file with a tabular format, such as a spread sheet. The reference implementation supports getting data only from a ResultSet object, but developers can extend the SyncProvider implementations to provide access to other tabular data sources.


Thanks,
Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can i get a clone of Resultset