Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding number of a rows in a resultset...

 
Chris Stewart
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to display data from a table in a jsp page. Instead of running through the resultset in the jsp page itself, I wanted to fill a 2d string array with the values. Well, you must specifiy a size for a 2d string array and I really won't know how many rows I need. Can anybody tell me how I can find the number of rows inside of a resultset? This way I can init my 2d array after I've run my SQL statement and populated the resultset.
Thanks.
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of an array, use an ArrayList. Then you don't need to know how long the array is beforehand, because you can add a new element dynamically for each row.
[ July 29, 2003: Message edited by: Ron Newman ]
 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought about that, but can it be 2d?
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have an ArrayList of array objects - presumably you know at compile time how many columns you have. (And if you somehow don't, you can also have an ArrayList of ArrayLists.)
 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing I can do a 4 col string array with 1 row and insert it into an ArrayList. I just wish there was a better way. unno:
[ July 29, 2003: Message edited by: Chris Stewart ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic