aspose file tools*
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet problem