Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

unexpected behavior from beforeFirst

38 views
Skip to first unread message

johngregg

unread,
Aug 6, 2004, 6:18:23 PM8/6/04
to
Hi all,

I'm using jConnect 5.5 and Sybase 11.92.

I'm getting some behavior from beforeFirst() that I don't
understand. The method name suggests and the Sun javadocs
say this method positions the cursor before the first record
in the result set, similar to the state when a result set is
first retrieved. However, I've found that if I run through
a result set once and call rs.beforeFirst(), I can then do
something like rs.getString(1) without calling rs.next() and
see the value of the first column of the first record. It
seems that this should give me an error because I haven't
called next yet. If this is the correct behavior, then
what's the difference between beforeFirst() and first()?

thanks

john

Paul

unread,
Aug 10, 2004, 2:25:40 PM8/10/04
to
Hi John,

That does not sound right! Could you post some of your code here so I can
get a better look?

PV

<John Gregg> wrote in message news:411403af.69d...@sybase.com...

Paul

unread,
Aug 11, 2004, 4:46:06 PM8/11/04
to
You need to post the code - my email will not let this through
<John Gregg> wrote in message news:41195e9f.176...@sybase.com...
> Check out the attachment. You can see how the behavior
> changes whether you use beforeFirst() or first() in
> printResultSet(). I think it should be an error to call
> beforeFirst(), then getObject(1) without calling next() in
> between. I also tested this with Oracle and it behaved the
> way I expected.
>
> thanks

Paul

unread,
Aug 11, 2004, 4:59:03 PM8/11/04
to
Opps - I got the code, my bad.

OK - I ran the test with EBF 11937 of the 5.5 driver. I think this might
have been a bug that is fixed. Check out my output:

This is using beforeFirst....

C:\temp>java Sybase x
c1=1
c2=test
c3=1234.5600
c4=2004-06-04 16:17:43.496
beforeFirst...
Exception in thread "main" java.sql.SQLException: JZ0R1: Result set is IDLE
as you are not currently accessing a row.
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:546)
at
com.sybase.jdbc2.jdbc.SybResultSet.checkIfReadableRow(SybResultSet.java:1634
)
at
com.sybase.jdbc2.jdbc.SybResultSet.getColumn(SybResultSet.java:1617)
at
com.sybase.jdbc2.jdbc.SybResultSet.getObject(SybResultSet.java:323)
at Sybase.main(Sybase.java:43)

C:\temp>


===================================================================

This uses first....

C:\temp>java Sybase x
c1=1
c2=test
c3=1234.5600
c4=2004-06-04 16:17:43.496
first...
rs = 1

C:\temp>

So what version of jConnect are you using?

PV

<John Gregg> wrote in message news:41195e9f.176...@sybase.com...


> Check out the attachment. You can see how the behavior
> changes whether you use beforeFirst() or first() in
> printResultSet(). I think it should be an error to call
> beforeFirst(), then getObject(1) without calling next() in
> between. I also tested this with Oracle and it behaved the
> way I expected.
>
> thanks
>
>
>

johngregg

unread,
Aug 12, 2004, 12:28:16 PM8/12/04
to
That error message looks like what I would expect. I don't
know what you mean by 'EBF 11937.' We're using 5.5. The
jconn2.jar's manifest file says it's build 25137. Are you
saying the fix is already available or that it's an internal
build?

thanks

Paul

unread,
Aug 12, 2004, 1:09:33 PM8/12/04
to
EBF 11937 is a patch of jConnect available for download - it is Build 25329.
You should be able to download it from the Sybase site. Apparently this was
some bug.

Pv
<John Gregg> wrote in message news:411b9aa0.4da...@sybase.com...

johngregg

unread,
Aug 12, 2004, 1:50:14 PM8/12/04
to
Yep, that fixed the problem. I noticed that the regular
jConnect 5.5 download page still contains the old build. No
way should that not have the latest and greatest. If you
want to make old versions available, put them somewhere else
and clearly mark them as obsolete.

thanks

0 new messages