I would like to know how to obtain the code of a combobox at the time of registering, and keep it in the database with its corresponding code, not the description. This is the code that filled the combos:
//METODO PARA CARGAR EL COMBOBOX "cboNivelArchivo"
@SuppressWarnings({ "unchecked", "rawtypes" })
void CargarComboNivelArchivo() {
Connection cn = null;
PreparedStatement pstm = null;
ResultSet rs = null;
try {
combo = new DefaultComboBoxModel();
cn = new MySqlConexion().getConectar();
String sql = "select * from TB_NIVEL_ARCHIVO_SA";
pstm = cn.prepareStatement(sql);
rs = pstm.executeQuery();
while (rs.next()) {
combo.addElement(rs.getString(2));
}
cboNivelArchivo.removeAllItems();
cboNivelArchivo.setModel(combo);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
if (pstm != null)
pstm.close();
if (cn != null)
cn.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}