Thread: interview prospective

Forum : New To Java   23-7-2017 09:47:16 AM
User Image
ArifKhan

Newbie

Joined: Jun 25, 2017

Points: 175

Threads: 115

Posts: 94

Answer Icon interview prospective

| Quote Date : Jul 23, 2017    Views:590    

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 : Jul 15, 2016

Points : 560

Threads: 641

Posts: 170

Answer IconRe: interview prospective

Reply Date : Jul 23, 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 : Jul 15, 2016

Points : 560

Threads: 641

Posts: 170

Re: interview prospective

Reply Date : Jul 26, 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 : Jun 25, 2017

Points : 175

Threads: 115

Posts: 94

Re: interview prospective

Reply Date : Jul 27, 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