I used a combo box to retrieve data from MySQL database. But when i inserted the first value set to database, combo box values are repeating. I want to know why it is happening and how to avoid it. i called this method on main. Thanks
public void FillCombo(){
try{
String sql = "Select Name from Employee where Position='Driver'";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next()){
op.add(rs.getString("Name"));
}
selectDriverC.setItems(op);
pst.close();
rs.close();
}
catch(Exception e){
System.out.println(e);
}
}
op
? Where is it defined? Are you sure it is empty when you callFillCombo
, and are you sure there are no repetitive values in the database itself? - James_D