This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes ResultSet problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet problem" Watch "ResultSet problem" New topic
Author

ResultSet problem

Vikas Kumar Sahu
Ranch Hand

Joined: Dec 02, 2003
Posts: 59
Hi All,
I am trying to access resultset two times like this
System.out.println(rs.getInt(1));
int i= rs.getInt(1);
but it is givine nodata found exception,
but if I remove System.out.println(rs.getInt(1)); it works fine.
So my question is why we can't access result two times for getting same data.
Raj Chila
Ranch Hand

Joined: Mar 18, 2004
Posts: 128

Hi Vikas,
the reason for that is that the default implementation of the Result set is of iterator pattern and the behaviour is scroll forward only. you can achieve this by changing the type of the Resultset Object to be created...I dont remember the syntax now...but some thing to do with the constants in the ResultSet class.
the other simple thing you could do it store the first getXXX return value in a local Variable and refer to this..you could avoid the burden on the result set.
hope this helps.
 
wood burning stoves
 
subject: ResultSet problem
 
Similar Threads
no dafault driver specified
How many connections
sql question
resultset and .first() query
how to retrive values of aggregate sql functions from resultset