File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Can I clone ResultSet? 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 "Can I clone ResultSet?" Watch "Can I clone ResultSet?" New topic

Can I clone ResultSet?

xiaorui chen

Joined: Sep 05, 2000
Posts: 9
ResultSet is interface, and hold the result after I query the database.
Can I open another space to hold that result set using cloning?
How can I do that?
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Strinctly a class which implements ResultSet doesn't hold any data. Drivers are free to go back to the database for each "next()". This is why a ResultSet is usually neither serializable nor cloneable.
What almost everyone does is read the results into some other data structure (a 2d array, a Vector of arrays, an ArrayList of Maps, whatever.) You can make that data structure serializable or cloneable if you wish.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: Can I clone ResultSet?
It's not a secret anymore!