I tried the below code and am getting values of "names" inside the while loop for a combo box.But coming outside the loop am only getting last value from database.
@FXML
private void fillcombobox()
{
try
{
String sql = "select * from location";
pst = gc.getConnection().prepareStatement( sql );
rs = pst.executeQuery();
while ( rs.next() )
{
String names = rs.getString( "Address" );
combobox.getItems().add( names );
}
}
catch ( Exception e )
{
System.out.println( "" + e );
}
}
The above code fetches all values from table location and get the all values present in column "Address". And using object names I am getting values in combo box now using this code:
combobox.getItems().add(names);
Please help me the possible way to get values outside the while loop.