This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes ResultSet problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ResultSet problem" Watch "ResultSet problem" New topic

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
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 could avoid the burden on the result set.
hope this helps.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: ResultSet problem
It's not a secret anymore!