This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes store recordset into array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "store recordset into array" Watch "store recordset into array" New topic
Author

store recordset into array

Yudi Ono
Greenhorn

Joined: Aug 24, 2008
Posts: 12
hi.

how to store recordset result into array?


thanks

regards

yudi




Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

When you say recordset, do you mean java.sql.ResultSet? If so, you need to iterate through the ResultsSet and for each row create an appropriate wrapper object (somehtign that encapsultes all the properties of the row), assign this object the values in the row then add it to the array.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Yudi Ono
Greenhorn

Joined: Aug 24, 2008
Posts: 12
thank you paul for the quick reply.

yes you are correct paul..java.sql.ResultSet is what i mean.

i have a result set like this.


could you please give me the example code?

thanks and regards


yudi
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

There is quite a detailed explanation in the JDBC tutorial (including examples). I suggest you have a read through that, you should find it useful.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43377
    
  32
Sounds like a thread which would sit better in the JDBC forum. Moving.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: store recordset into array
 
It's not a secret anymore!