• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC ResultSet

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've a requirement, where i need to proceed only
if the resultset contains more than one record, otherwise not.
Please let me know what should i do to know about this.
I heard that getfetchsize() cannot do this.
Thanks in Advance
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no.
A fetchsize is used for caching more or less results.
Of course, if the database supports 'fetchsize', there might not be much use in a fetchsize < 2.
But since it isn't build for counting results, I wouldn't like to stick on it.
At least I would read the documentation of fetchsize very carefully - Perhaps the fetchsize is allways '200', even if there is only one result?
'select count (*) ...' would be the ordinary way.
Scrolling forward and back would be a workaround too, but as far as I know, not every vendor supports scrollable resultsets, and maybee it depends on query-details too.
You could get dependent on a specific database that way.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seetarama,
Alternatively, you could do something like the following:

You wouldn't incur extra overhead this way by having to do another query.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic