try {
ResultSetMetaData rsmd = rs.getMetaData();
if (rsmd.getColumnCount() == 1) {
while (rs.next()) {
Item item = new Item(rs.getObject(1), rs.getObject(1));
((JComboBox)component).addItem(item);
}
} else {
while (rs.next()) {
StringBuffer sb = new StringBuffer();
for (int i = 2; i < rsmd.getColumnCount(); i++)
sb.append(rs.getObject(i) + " | ");
sb.append(rs.getObject(rsmd.getColumnCount()));
Item item = new Item(rs.getObject(1), sb.toString());
((JComboBox)component).addItem(item);
}
}
rs.close();