i have 1000 records in resultset, how to get first 100
records from resultset, because resultset fetch all 1000
records at a time?
Answers were Sorted based on User's Feedback
Answer / sumit
The question is not pretty clear. However, before retriving the records from the database if you want to make sure you get only 100 records in one hit. U can use the following API after creating the statement object.
Statement.setFetchSize(100);
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / chandra
There is two ways to getting the limited records from the
DB.
1)we can use sql command :
set rowcount 100 select * from mytab.
2)Instead of set rowcount you can use setMaxRow(100) method.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / dmk.java@gmail.com
query should be prepare like this
select * from tab_name where rownum <= 100
Is This Answer Correct ? | 6 Yes | 3 No |
Answer / a kumar
If your intention is to dislay only 100 records to the
user, then better make the change the query to retrieve
first 100 recs. (like say fetch first 100 rows in Db2).
Is This Answer Correct ? | 4 Yes | 4 No |
Answer / saket
GO ON LINK JAVATEACHER.CO.IN AFTER THAT CLICK JSP ,,,,THERE
IS AN EXAMPLE OF PAGINATION SHOW THAT EXAMPLE THAT IS
PERFECT EXAMPLE FOR U
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / ravi
the is a syntax in sql 'limit'....using this u can get
desired number of rows...
suppose database having 1000 rows..
query will be:
select * from table limit 100;
first 100 rcds will be selected...
Is This Answer Correct ? | 2 Yes | 5 No |
How can I create a custom RowSetMetaData object from scratch?
What are cursor attributes?
Is jpa faster than jdbc?
What is odbc and jdbc?
What is jdbc connection?
What is the execute method in java?
How do I load a database driver with JDBC 4.0 / Java 6?
When does the result for an sql statement return null?
How java can be connected to a database?
How do I receive a ResultSet from a stored procedure?
How do java applications access the database using jdbc?
Explain some new features available in jdbc 4.0?