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
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...
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
>
>
>
thanks
Pv
<John Gregg> wrote in message news:411b9aa0.4da...@sybase.com...
thanks