This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes fetch data at a given record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "fetch data at a given record" Watch "fetch data at a given record" New topic
Author

fetch data at a given record

Faiz Abdelhafid
Ranch Hand

Joined: Nov 21, 2009
Posts: 32
Hello,

what I should use with the Result Set, in order to obtain just the first record or any other record.

Thanks
Faiz Abdelhafid
Ranch Hand

Joined: Nov 21, 2009
Posts: 32
Problem solved.

Thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

Faiz, while it is good that you solved your problem, it would have been better if you posted the solution for the benefit of Ranchers who will run into this problem in the future.


JBoss In Action
Faiz Abdelhafid
Ranch Hand

Joined: Nov 21, 2009
Posts: 32
Peter Johnson wrote:Faiz, while it is good that you solved your problem, it would have been better if you posted the solution for the benefit of Ranchers who will run into this problem in the future.


Dear Peter,

No problem !


well I was looking for a method to use with the Result Set in order to fetch records in a given order inside a Thread. The exercise is to refresh a text string every 45 sec from the database.

you can use "absolute" method to move the cursor used to fetch data to any given record inside the table.

here is the code:



Hope this will help
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

This might not be the best approach. The call to PreparedStatement.execute() might actually retrieve a number of records from the database and buffer them, at which point you ask for only one record. This wastes the database's time and network bandwidth. Most databases provide SQL syntax to limit the results return for a query - you would be better off using such a mechanism. One caveat though - the SQL mechanism is not database independent.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fetch data at a given record
 
Similar Threads
Exhausted Resultset exception when result count is huge.
Struts Survey - Please respond
WA #1.....word association
Getting Last Record in Jtable
over 100,000 visits to The Big Moose Saloon yesterday