• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

size and next method

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a CachedRowSet object loRS.

but when it comes to the if loop, it fails and goes to the else loop.
Can someone please tell me, why eventhough the size of the object is 1, why loRS.next is being executed to false.
Many Thanks!!
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Here You've written if(loRS.next()) that increase the Resultset to the next elements.Since there is only 1 element and after performing operation loRS.next it has left with nothing. Try this

boolean b = loRS.next()
if(b){
System.out.println("Do something with the value");
}else{
System.out.println("No row in the result set");
}



Thanks
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont have much idea about CachedRowSet but the problem might be because the iterator could be pointing to the current element and when you call next() it could go out of bounds and so condition may have failed. Is there a hasNext()? If it is there you could try that.
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, thats not working
 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
Its working. The problem was that for debugging i have already used next() method in my application somewhere. So, the next time i am trying to increment it and it is returning no rows. Anyways thanks guys for your valuable suggestions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic