• Post Reply Bookmark Topic Watch Topic
  • New Topic

A simple Question -need help!!!!  RSS feed

 
Naf Rash
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm having a problem. I ahve the following piece of code. it compiles and runs. it displays the table that has been connected to but I also want to transfer the table into an array and for some reason I can't do this. Why? At the moment the code prints the lines upto "getting before bforeFirst" and not passed this. Please help- why is this?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
REsultSets start at a position before the first record (hence 'before first').
You have to call if(rs.next()) before trying to access any data from the ResultSet. This returns true if there is a next() item, and moves the cursor forward one.
therefore get rid of your do... while and turn it into a while loop.
Dave
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!