Good day! I have a problem, I am trying to fill a JComboBox from mysql, and I can not! :( The console does not send me an error but it does not show anything either, I'm just starting in this and I do not have much experience! Hopefully someone can help me ... I leave the code here:
// GridBagLayout
this.setLayout(new GridBagLayout());
GridBagConstraints left = new GridBagConstraints();
GridBagConstraints right = new GridBagConstraints();
GridBagConstraints wide = new GridBagConstraints();
left.gridx = 0;
left.anchor = GridBagConstraints.LINE_END;
right.gridx = 1;
right.anchor = GridBagConstraints.LINE_START;
wide.gridwidth = 2;
wide.fill = GridBagConstraints.HORIZONTAL;
//*********Aqui esta mi combobox****
wide.gridy++;
patron = new JComboBox();
this.add(patron, wide);
patron.setBackground(colorAzulM);
Here is my method, I'm doing it in the same class, I do not know if that has to do!
Pool metodospool = new Pool();
java.sql.Connection cn = null;
ResultSet rs = null;
Statement st=null;
private void cargarcombopatron() {
try {
String sql= "select Als from dig_hrpatron";
cn= metodospool.dataSource.getConnection();
cn.createStatement();
rs = st.executeQuery(sql);
System.out.println(sql);
while(rs.next())
{
patron.addItem(rs.getString(1));
}
} catch (SQLException ex) {
Logger.getLogger(StructurePropertiesPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
I hope your help !!! Thank you very much :)