• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC ResultSet

 
seetarama raju
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • 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
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • 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.
 
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
Seetarama,
Alternatively, you could do something like the following:

You wouldn't incur extra overhead this way by having to do another query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic