• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet problem

 
Vikas Kumar Sahu
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic