File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Resultset doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Resultset doubt" Watch "Resultset doubt" New topic

Resultset doubt

Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
I have a db-access code inside a JSP which has to display 'no value found' if there are no matching values.
Well, I tried like this..

then I tried like this..
and this worked.
My doubt is why is the resultset never 'zero' even when there are no matching values. Can someone tell me where I am going wrong?

Discipline, Dedication and Determination define Destiny.
Rudy Dakota
Ranch Hand

Joined: Jul 27, 2002
Posts: 54
Hi Nandini,
From your post I get the strong impression you suppose getFetchSize() will return the number of rows actually retrieved. This is not the case. In fact, there is no easy way in JDBC to determine that number. Your second solution is the 'good' one.
Oh, by the way, you might want to read the documentation on JDBC. There is plenty that will tell you what the methods actually do.
Good riding,
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You need:

I'm not sure whether my explanation is accurate, but I think a fetchSize is a kind of BufferSize; the number of rows which can be passed by the database at once. You may set it explicitly with 'setFetchSize ()' and it may be smaller or greater than the count of rows returned.
[ April 06, 2004: Message edited by: Stefan Wagner ]
Nandini Sriram
Ranch Hand

Joined: Jul 04, 2003
Posts: 132
Thanks Rudy and Stefan. I will look into it.
I agree. Here's the link:
subject: Resultset doubt
It's not a secret anymore!