Thread: interview prospective

Forum : New To Java   23 Jul, 2017 13:47
User Image
ArifKhan

Newbie

Joined: 25 Jun, 2017

Points: 175

Threads: 118

Posts: 94

Answer Icon interview prospective

| Quote Date : 23 Jul, 2017    Views:724    

Suppose the SELECT returns 1000 rows, then how to retrieve the first 100 rows, then go back and retrieve the next 100 rows?

tags: jdbc

Comments

User Image
Sriman

Member

Joined : 15 Jul, 2016

Points : 1000

Threads: 645

Posts: 201

Answer IconRe: interview prospective

Reply Date : 23 Jul, 2017

To accomplish this we need to implement pagination.
The implementation will differ from technologies and databases we are using
For e.g. while using jdbc and mysql we can use LIMIT START AND END
If we are using Hibernate, it has in-built support for Pagination.

User Image
Sriman

Member

Joined : 15 Jul, 2016

Points : 1000

Threads: 645

Posts: 201

Re: interview prospective

Reply Date : 26 Jul, 2017

Arif,

Your answer is wrong, Statement.setFetchSize(size) is going to instruction how many records should be fetched from database when we call rs.next().
But we cannot navigate First 100 rows and next 100 rows using this. You have to write pagination logic.

"Use the Statement.setFetchSize method to indicate the size of each database fetch.
"

Replied by ArifKhan
User Image
ArifKhan

Newbie

Joined : 25 Jun, 2017

Points : 175

Threads: 118

Posts: 94

Re: interview prospective

Reply Date : 27 Jul, 2017

Use the Statement.setFetchSize method to indicate the size of each database fetch.

To accomplish this we need to implement pagination.
The implementation will differ from technologies and databases we are using
For e.g. while using jdbc and mysql we can use LIMIT START AND END
If we are using Hibernate, it has in-built support for Pagination.

Replied by Sriman
Load More

No More Comments