• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I clone ResultSet?

 
xiaorui chen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Thanks!
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic