Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I create an array from a recordset?

Status
Not open for further replies.

Gaz1634

Technical User
Oct 8, 2002
22
GB
Hi,

Can anyone advice me how to move the contents of a recordset into an array.

I am trying to move the data into an array of objects, Customers to be specific. I have created the Customers class and that works, and can pull the contents off of the oracle DB into a recordset, but cant move it to an array. Can anyone help?
 
So.. you can create a "Customer" instance for each entry in the recordset, and add this to an ArrayList. An ArrayList is more flexible than an array, but you can convert the ArrayList to an array of Objects (i.e. Customer[]) by using

ArrayList customerList = new ArrayList;

for each element in record set, create a Customer.
{
customerList.add(customer);
}

Customer[] array = (Customer[])customerList.toArray(new Customer[]{});
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top