• Post Reply Bookmark Topic Watch Topic
  • New Topic

JDBC ResultSet Doubt  RSS feed

 
Anindya Dutta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I extract a ResultSet from a database. I now want to extract another ResultSet from this ResultSet. how to do?
e.g, I have a ResultSet with all fruits that have color='red'. Now I need to extract all fruits tht have color='red' and taste='sweet'. So I want to extract a ResultSet from this ResultSet such that taste='sweet'.
Help appreciated. Thank you.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why can't you do a new query on the DB for 'red' and 'sweet'?
 
Anindya Dutta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is because the two conditions have not been specified together, they have been, after an interval of time; and there will be many inputs following it, I need to keep reducing the dataset each time to fulfil the final result. accessing the db each time will increase the no. of accesses to the db, also, since a large no. of entries exist in the db, the whole process will take a lot of time, if each time i access the db.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you not handle the issue at the point where the ResultSet is consumed?
 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not recommend using the ResultSet for this kind of manipulation. The ResultSet is a convenience class provided by the java.sql package that we can use to get hold of the contents of a jdbc query.

I would recommend mapping the contents of your ResultSet into a Collection of things relevant to your application domain and then performing the filtering on that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!