Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the use of setFetchSize and setMaxRows methods in Statement.

 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


what is the use of setFetchSize and setMaxRows methods in Statement?

what is the use of setFetchSize method in ResultSet? ( Already Statement has
setFetchSize method)

thanks,
Thennam Pandian.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4032
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thennam Pandian:
what is the use of setFetchSize method in ResultSet? ( Already Statement has setFetchSize method)


The answer to the second question comes straight from the ResultSet API:

Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed for this ResultSet object ... The default value is set by the Statement object that created the result set.
 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Let us take this example. i have 10 Laksh row in a student table.

1. i am using the query "select * from student". By default how many row will be selected by statement obj?

2. Assume that the default value is 50,000. how can i get the remaining rows of the table.

3.what is the difference between fetchSize and setMaxRow?

thanks,
Thennam Pandian.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thennam,
1) All of them
2) The default value of what? maxRows defaults to returning all the rows
3) maxRows is the number of rows that can be returned overall. fetchSize is the number that will be returned in each database roundtrip
 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can you give me a practical example for both.

thanks,
Thennam
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thennam,
Normally, I wouldn't use either one. If I learned I had a network traffic problem, I might try increasing the fetch size. I would never use maxRows because I prefer limiting the rows from the SQL itself.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
I would never use maxRows because I prefer limiting the rows from the SQL itself.


Since the SQL based 'fetch size' solutions are DB dependent, I guess you could use maxRows if you wanted a DB agnostic solution. Having said that, everyone I know would make the same decision as Jeanne.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic