Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Searching a ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Searching a ResultSet" Watch "Searching a ResultSet" New topic
Author

Searching a ResultSet

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I am using java sql to get remote record data. After I get the ResultSet is there a faster way to searh for the existance of a string within the ResultSet other than iterating through the records with while loop?
Istvan Kovacs
Ranch Hand

Joined: May 06, 2010
Posts: 100
Steve Dyke wrote:I am using java sql to get remote record data. After I get the ResultSet is there a faster way to searh for the existance of a string within the ResultSet other than iterating through the records with while loop?


I don't know of any. Maybe you should change your SQL query to make the information you need more readily available?
Nevin kumar
Ranch Hand

Joined: Mar 15, 2008
Posts: 93
You can try Google's java collections,lambdaj features. you can apply filtering on all sort of collections.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Nevin: won't be any faster, though, just cleaner.

@Steve: no. As Istvan said, maybe querying better would be a cleaner solution.
Manish Singh
Ranch Hand

Joined: Jan 26, 2007
Posts: 160
Fastest possible way would be an exact query to be sent to the DB. as the DB might make use of proper indexing and the unnecessary data wont travel from DB to the java machine.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

I agree with Istvan and Manish. Let the database server do the hard work, and as a bonus get less results so less network traffic.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Searching a ResultSet
 
Similar Threads
resultset data stored in database or java
how can I get Record Count from ResultSet?
Clarrifications about ResultSet object?
jsp resultset
Exhausted Resultset exception when result count is huge.