[thelist] Weird Thing in Java ResultSets

david.landy at somerfield.co.uk david.landy at somerfield.co.uk
Mon Apr 26 10:37:47 CDT 2004


Hi Everyone,

There was a thread a little while ago about strange problems accessing data
in ASP. 

I'm now experiencing something very similar in Java and thought I'd post a
workaround in case anyone else gets caught by it. 

<tip type="java database access" author="david landy">
When attempting to retrieve field data from a java ResultSet, you may find
that the *second* attempt to retrieve a field for the current row gives you
a "No data found" error.

For example:

String a1 = rs.getString("a"); // retrieves data
String a2 = rs.getString("a"); // --> Error 0: No data found <--

To prevent this occurring, make sure to retrieve the field values of the
current row only once.

Each time the row pointer is moved, by eg calling next(), the field can be
fetched again.

This behavious has been observed on ms-access databases via the jdbc:odbc
bridge, but may not be confined to this configuration.
</tip>

-- 
David Landy, IT Consultant, Business Intelligence
Somerfield/KwikSave Support Centre
Whitchurch, Bristol, UK. Tel: 0117 301 8977
david.landy at somerfield.co.uk <mailto:david.landy at somerfield.co.uk>    
 
"...Our deepest fear is not that we are inadequate. Our deepest fear is
that we are powerful beyond measure." - From A RETURN TO LOVE by
Marianne Williamson © 1992	


 
If you are not the intended recipient of this e-mail, please preserve the
confidentiality of it and advise the sender immediately of any error in
transmission. Any disclosure, copying, distribution or action taken, or
omitted to be taken, by an unauthorised recipient in reliance upon the
contents of this e-mail is prohibited. Somerfield cannot accept liability
for any damage which you may sustain as a result of software viruses so
please carry out your own virus checks before opening an attachment. In
replying to this e-mail you are granting the right for that reply to be
forwarded to any other individual within the business and also to be read by
others. Any views expressed by an individual within this message do not
necessarily reflect the views of Somerfield.  Somerfield reserves the right
to intercept, monitor and record communications for lawful business
purposes.


More information about the thelist mailing list