 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
steve Guest
|
Posted: Sat Mar 06, 2004 9:14 am Post subject: need help with the following code (vector) |
|
|
I have the following code that pulls the menu items from a database
private JComboBox suppgrp = new JComboBox();
Vector SupGrps=SQL_stuff.getsuppliergroups();//this gets the supplier group
areas.
//here we need to setup the list
Object[] stArray = SupGrps.toArray();
for (int i = 0; i < SupGrps.size(); i++) {
String motherf =stArray[i].toString();
suppgrp.insertItemAt(motherf, i);
}
the setup sql code is
while (rset.next()) {
String[] record1 = new String[ColumnCount];
for (int i = 0; i < record1.length; i++) {
record1[i] = (String) rset.getString(i + 1); // COPY THE
DATA TO A LOCAL ARRAY OF THE RIGHT SIZE
}
loop++;
supgrp.addElement(record1);
}
but when displayed the list holds.
[Ljava.lang.String;@663a54
[Ljava.lang.String;@xxxxxx
[Ljava.lang.String;@xxxxxx
however both the vector SupGrps & the object stArray are showing the actual
strings when viewed in a debugger.
I guess it's " String motherf =stArray[i].toString();"
any ideas
|
|
| Back to top |
|
 |
steve Guest
|
Posted: Sat Mar 06, 2004 10:30 am Post subject: Re: need help with the following code (vector) |
|
|
On Sat, 6 Mar 2004 17:14:43 +0800, steve wrote
(in article <0001HW.BC6FB783000FD074F03055B0 (AT) news (DOT) newsguy.com>):
| Quote: | I have the following code that pulls the menu items from a database
private JComboBox suppgrp = new JComboBox();
Vector SupGrps=SQL_stuff.getsuppliergroups();//this gets the supplier group
areas.
//here we need to setup the list
Object[] stArray = SupGrps.toArray();
for (int i = 0; i < SupGrps.size(); i++) {
String motherf =stArray[i].toString();
suppgrp.insertItemAt(motherf, i);
}
the setup sql code is
while (rset.next()) {
String[] record1 = new String[ColumnCount];
for (int i = 0; i < record1.length; i++) {
record1[i] = (String) rset.getString(i + 1); // COPY THE
DATA TO A LOCAL ARRAY OF THE RIGHT SIZE
}
loop++;
supgrp.addElement(record1);
}
but when displayed the list holds.
[Ljava.lang.String;@663a54
[Ljava.lang.String;@xxxxxx
[Ljava.lang.String;@xxxxxx
however both the vector SupGrps & the object stArray are showing the actual
strings when viewed in a debugger.
I guess it's " String motherf =stArray[i].toString();"
any ideas
|
Sorry too much time looking at the code
Obviously the correct solution is:
Vector SupGrps=SQL_stuff.getDatabaseArray(2);//this gets the supplier group
areas.(2 cols)
//here we need to setup the list
int i=0;
for (Iterator it=SupGrps.iterator(); it.hasNext(); ) {
Object element = it.next();
String[] stArray = (String[])element;
suppgrp.insertItemAt(stArray[0], i++);
}
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|