0
Well I have a DAO class Departamentosdao I wanted to popular a combo box with a consultation I do in this DAO
my DAO:
public class DepartamentoDAO {
private Connection con;
public DepartamentoDAO() {
this.con = new ConnectionFactory().getConnection();
}
public boolean popularComboBox() throws SQLException{
List<String> setores = new ArrayList<String>();
String query = "SELECT * FROM departamentos";
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while(rs.next()){
setores.add(rs.getString("nome_setor"));
}
ps.close();
return true;
}
}
my controller:
@FXML
private JFXComboBox<Departamento> cbDepart;
private List<Departamento> departamentos = new ArrayList();
how I could popular my combo box with that DAO list that is in another way?