× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



allready thought of something like that. thanx.

On 2002.08.09 12:55 Richard Dettinger wrote:
>
> re: I think that if no rows are returned, rather
> than an empty ResultSet you get a null one;
>
> No, you should get a ResultSet which is empty.  Calling next() the first
> time will return false.  So the
> code example below will always work.  If you needed to know to do
> something
> different when it was
> empty, you could probably either keep a int count inside your while loop
> which you checked after
> the loop ended (if the int was still 0, it was null).
>
> Or perhaps something like this:
>
> int i;
> for (i = 0; rs.next(); i++) {
>       // process row.
> }
>
> if (i == 0) {
>       // handle empty case.
> }
>
> There are other things that should work as well with scrollable
> resultSets.
> (such as using
> first() or isBeforeLast()), but my experience is that different drivers
> would be more spotty
> and less consistant in this area and something like the above solution is
> a
> better idea.
>
> Richard D. Dettinger
> iSeries Java Data Access Team
>
> Democracy's enemies have always underestimated the courage of the
> American
> people.
> It was true at Concord Bridge.  It was true at Pearl Harbor.  And it was
> true today.
>
>          Rochester Post-Bulletin
>          Tuesday September 11, 2001
>
>
> |---------+---------------------------->
> |         |           "McCallion,      |
> |         |           Martin"          |
> |         |           <martin.mccallion|
> |         |           @misys.com>      |
> |         |           Sent by:         |
> |         |           java400-l-admin@m|
> |         |           idrange.com      |
> |         |                            |
> |         |                            |
> |         |           08/09/2002 05:15 |
> |         |           AM               |
> |         |           Please respond to|
> |         |           java400-l        |
> |         |                            |
> |---------+---------------------------->
>   
>>------------------------------------------------------------------------------------------------------------------------------|
>   |
>                                                        |
>   |       To:       "'java400-l@midrange.com'" <java400-l@midrange.com>
>                                                        |
>   |       cc:
>                                                        |
>   |       Subject:  RE: howto figure out if ResultSet is empty
>                                                        |
>   |
>                                                        |
>   |
>                                                        |
>   
>>------------------------------------------------------------------------------------------------------------------------------|
>
>
>
> Mihael Knezevic wrote:
>
> > howto figure out if ResultSet is empty ?
> >
> > my code looks like this:
> >
> > Statement statement;
> > ResultSet rs;
> >
> > String stm = "Select xxx from xxx.xxx where xxx";
> >
> > rs = statement.executeQuery(stm);
> >
> > while(rs.next())
> > {
> >            do.something();
> > }
>
> I'm not entirely sure, but I think that if no rows are returned, rather
> than an empty ResultSet you get a null one; so just test it for null
> first.  As well as that, if there is no row available (presumably, even
> if there are no rows to begin with) next() should return false.
>
> Cheers,
>
> Martin.
>
> --
> Martin McCallion
> Senior Technical Consultant
> Work:  martin.mccallion@misys.com
> Home: martin.mccallion@ukonline.co.uk
> Misys International Banking Systems
> 1 St George's Road, London, SW19 4DR, UK
> T +44 (0)20 8486 1951
> F +44 (0) 20 8947 3373
> www.misys.com
> This email message is intended for the named recipient only. It may be
> privileged and/or confidential. If you are not the  intended named
> recipient of this email then you should not  copy it or use it for any
> purpose, nor disclose its contents to any other person. You should
> contact Misys International Banking Systems as shown below so that we
> can take appropriate action at no cost to yourself.
> Misys International Banking Systems Ltd,1 St
> George's Road, London, SW19 4DR, UK. Email: ibs.postmaster@misys.com.
> Tel: +44 (0) 20 8879 1188 Fax: +44 (0) 20 8947 3373
> Misys International Banking Systems Ltd is
> registered in England and Wales under company no. 971479
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400
> (JAVA400-L)
> mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>
>
>
>
>
> _______________________________________________
> This is the Java Programming on and around the iSeries / AS400
> (JAVA400-L) mailing list
> To post a message email: JAVA400-L@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
> or email: JAVA400-L-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/java400-l.
>
>


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.