It turns out that in a mysql database I have some registry and I need to be reflected in a java JComboBox but I can not find the error
I have a class that takes care of the connection to the database and inside it I do that method
106 public void llenarCmbCurso(JComboBox cmbCurso){
107 cmbCurso.removeAllItems();
108 try{
109 String query = "SELECT C_codCurso FROM t_curso ";
110 PreparedStatement ps =conect.prepareStatement(query);
111 ResultSet rest = ps.executeQuery();
112
113 while(rest.next()){
114 cmbCurso.addItem(rest.getString("C_codCurso"));
115 }
116
117 }catch(SQLException e ){
118 System.out.println(e.getMessage());
119
120 }
121 }
In JFrame where I want to show such a thing I do the following
18 Conexion con = new Conexion();
19 public FMateria() {
20 initComponents();
21 this.setLocationRelativeTo(null);
22 deshabilitar();
23 con.llenarCmbCurso(cmbCodCurso);
24 }