Hi,
I got a problem.I wan to diaplay all the records of the database to JcomboBox .I used Vector.but the records are not displaying in the jcombobox.It is printing the values in the console. I think the problem is with the line ' itemno=new JComboBox(result);'. I am getting the values from the selectItemID() method.but it is not assigning it to the jcombobox.
The code:-
public Vector selectItemID(){
Vector result = new Vector();
try {
statement = dbConnection.prepareStatement("select ItemId from ItemDetails");
ResultSet itemNumberResult = statement.executeQuery();
while(itemNumberResult.next())
{
String itemNo = itemNumberResult.getString(1);
System.out.println("itemNo " +itemNo);
result.add(itemNo); // add all found itemNos
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
DbActivity dbconnection = new DbActivity();
Vector result= dbconnection.selectItemID();
itemno=new JComboBox(result); // construct Combo with Vector
//System.out.println("Result "+result);