Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes how to get a number of record from the Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "how to get a number of record from the Resultset " Watch "how to get a number of record from the Resultset " New topic
Author

how to get a number of record from the Resultset

Robert Smith
Greenhorn

Joined: Oct 14, 2003
Posts: 23
how to get a number of record from the Resultset ? for example , from 10 rows to 20 rows records ,please give me some examples!
thanks!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
"skyspeed skyspeed",
Your more than welcome to the JavaRanch but your display name does not comply with our naming policy so I'll have to ask you to change it.
Thanks.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Sainudheen Mydeen
Ranch Hand

Joined: Aug 18, 2003
Posts: 218
Hi
Inside while(rs.next()) loop you can write a logic to skip the first 9 records and the records after 20.
-Sainudheen
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8264

If your database supports the TOP keyword you can use a subquery to ORDER BY x ASC and get the top 20, and have the outer query ORDER BY x DESC and get the top 10.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Robert Smith
Greenhorn

Joined: Oct 14, 2003
Posts: 23
thanks !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get a number of record from the Resultset
 
Similar Threads
How to find the number of rows in the resultset
Can we extract the data from resultset after the connection get closed.
Resultset row count
How to know no of records resultset contains in xml file
setFetchSize() ??