Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

holding multiple values in an array

Thread view: 
Praveen - 18 May 2006 19:45 GMT
Hi..,

  While parsing a XML files I need to hold some of the values in an
array till the end of the iteration. After that I need to dump the
values in the DB table.

Here is an eg.
- These are the 4 values I want to hold from each file after I parse them.
Name, dept_no, employee_id, state

How do i create an array?
Matt Humphrey - 18 May 2006 19:56 GMT
> Hi..,
>
[quoted text clipped - 7 lines]
>
> How do i create an array?

What you're asking for is something like

String [] values = new String [4];
values[0] = name;
values[1] = dept_no;

but this is a poor way to go because it obscures the names of the fields.
It sounds more like you need a class, as is

class Employee {
 String name;
 String dept_no;
 String employee_id;
 String state;
}

create a new Employee each time you encounter the values.  There are some
automated systems for doing this, but I havn't used them.

Alternatively, if you could put the fields into a map, as in
Map map = new HashMap ();
map.put ("name", name);
map.put("dept_no", dept_no);
etc.

I don't recommend this unless you are assured there is a an exact map
between your incoming data and your database schema.

Cheers,
Matt Humphrey matth@ivizNOSPAM.com  http://www.iviz.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.