Hi,
I am new to java.Can u Plz help me.I have a JcomboBox. I want to display all the ItemId from the database in that JComboBox. I don't know how to do that.Its Displaying only 1 item.ie.first record.Can any one plz help me.
The code is:-
public String selectItemID(){
String itemNo = null;
try {
statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
ResultSet itemNumberResult = statement.executeQuery();
while(itemNumberResult.next())
{
itemNo = itemNumberResult.getString(1);
System.out.println("itemNo " +itemNo);
//itemNumber = ArrayList.class.
//System.out.println(" itemNumber = " + itemNumber);
return itemNo ;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return itemNo;
}
DbActivity dbconnection = new DbActivity();
String result= dbconnection.selectItemID();
itemno.addItem(result);