wood burning stoves 2.0*
The moose likes JDBC and the fly likes get a limited no of records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "get a limited no of records" Watch "get a limited no of records" New topic

get a limited no of records

kevin Johnson

Joined: Jul 24, 2001
Posts: 1
Hi there,
resultSet.next gives me all the rows from the table. Is there any way to limit the no of records say only 10??

// print out records

//String[] row = new String[columnCount];
for(int i=1; i<columnCount+1; i++) {>
entry = resultSet.getString(i) + ",";

Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
or in Oracle you can have ROWNUM < 11 in the where clause
It is sorta covered in the JavaRanch Style Guide.
subject: get a limited no of records
Similar Threads
getObject() method is not returning the proper result.
comparing two ResultSet
Making arraylist from resultset
JTable won't display records from database
Get results from user defined query