This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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

 
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.
 
author
Posts: 4107
28
Google Web Toolkit Eclipse IDE Flex
  • 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.
 
author & internet detective
Posts: 39396
763
Eclipse IDE VI Editor Java
  • 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
Posts: 39396
763
Eclipse IDE VI Editor Java
  • 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.
 
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
Boost this thread!