× 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.



Here is a link to the java2 1.3.1 platform sdk documentation on resultsets.
http://java.sun.com/j2se/1.3/docs/api/java/sql/ResultSet.html

As stated you can
    rs.previous()
    rs.next()
    rs.first()
    rs.last()

    and so on.

In VB you do have the ability with recordsets to do the following:
if rs.bof and rs.eof then 'this will check if the recordset actually has
data without moving the cursor

Unfortunately there is no equivalent in java to bof or eof.
However if you:
ResultSet rs = stmt.ExecuteQuery("Select * from table") ;

if ( !rs.next() )
    // no rows found
else
    do    {
    // a row was found and process
    } while ( rs.next() )

One possible workaround.

BTW the same logic scenario here is the same as embedded SQL in RPG.  You
must declare a cursor, open the cursor and then fetch the cursor.  If sqlcod
= 100 then no rows are retrieved

c/exec sql
 + declare @c1 cursor for select * from table
c/end-exec

c/exec sql open @c1
c/end-exec

c/exec sql fetch @c1 into :cursorvar
c/end-exec

c                        if         sqlcod <> 0
c*  no rows found or error
c                        endif

c                        dow    sqlcod = 0
 * logic for processing rows
c/exec sql fetch @c1 into :cursorvar
c/end-exec
c                        enddo

...
HTH
Dan

----- Original Message -----
From: "Price, Chris" <chris_price@nsb.co.uk>
To: <java400-l@midrange.com>
Sent: Tuesday, November 27, 2001 9:34 AM
Subject: RE: JDBC Style


> This message is in MIME format. Since your mail reader does not understand
> this format, some or all of this message may not be legible.
> --
> [ Picked text/plain from multipart/alternative ]
> Thanks for the answer Dan.
>
> The "problem" I have with using next() to determine if a record set is
empty
> , is that it moves the file pointer (oops - betraying my RPG origins now)
I
> mean cursor, so the result set is changed. I know I can move it back
again,
> but this seems a bit sloppy to me, hence my post.
>
> The problem may well of course be mine, I'm that I'm still thinking like
an
> RPG programmer and want to know why I can't have my file indicators
> back....(VBG)
>
> Chris
>
> -----Original Message-----
> From: Dan Hoover [mailto:dan@hooversys.com]
> Sent: 27 November 2001 14:20
> To: java400-l@midrange.com
> Subject: Re: JDBC Style
>
>
> if (!rs.next() ) {}
>
> HTH
> Dan
> ----- Original Message -----
> From: "Price, Chris" <chris_price@nsb.co.uk>
> To: <java400-l@midrange.com>
> Sent: Tuesday, November 27, 2001 9:11 AM
> Subject: JDBC Style
>
>
> > This message is in MIME format. Since your mail reader does not
understand
> > this format, some or all of this message may not be legible.
> > --
> > [ Picked text/plain from multipart/alternative ]
> > All,
> >
> > What the best (most elegant, most efficient) way to determine if a JBDC
> > Result Set is empty?
> >
> > Chris
> >
> >
> >
> > _______________________________________________
> > 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.
> _______________________________________________
> 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.