hi, u don't need to generate another resultset:
ResultSet rs = executeQuery(Select);
boolean hasResults = rs.next();
 if (!hasResults) {
 ....
 }
 else {
            do{
                ....
            }
            while (rs.next)
       }

regards
Ying


----- Original Message -----
From: "Vijay Nair" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 31, 2000 4:53 AM
Subject: Re: Check the JDBC result value


> Hi Rus
>
> This loop should help u
> int counter =0;
> while(rs.next()){
>  .... extract values
> counter++;
> }
>
> u could also have a counter for numbers initialize it to zero before the
loop
> and if it's still zero after the loop, the u know ur query returned null.
the
> disadvatange of using
> the following(with due apologies to Matthias):
> ResultSet rs = executeQuery(Select);
> boolean hasResults = rs.next();
> if (!hasResults) {
> ....
> }
> else {
>         while (hasResults) {
>         ...
>         hasResults = rs.next();
>         }
> }
> is that u will have skipped one item in the query due to ur having asked
it to
> go to the next item(rs.next()) during ur check. The only way around this
is
> creating another resultset, which, needless to say is a waste of time
given
> that there r easier solutions.
>
> hope this helps
>
> regards
> vijay
>
> Rusmawidya Ustati wrote:
>
> > Hi,
> >
> > I have a question about a database to servlet connection.
> > Does anyone know how to check if a query returns a null value in the
> > ResultSet.
> > Thanks.
> >
> > Rusma
> >
> >
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to