try{
Statement stmt = c.createStatement();
String sql = "select * from tab_cliente Where nome like '%"+cb_nomecliente.getSelectedItem()+"%'";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
// isso se o campo cod_cliente for String
jcombobox_codcliente.addItem(rs.getString("cod_cliente"));
}
}catch (Exception erro) {
JOptionPane.showMessageDialog(null,
"Erro a tentar excluir o registro..." + erro);
}
private void inicializaCombobox() throws Exception {
try {
stmt = bd.ConexaoBancoDados.conexao().createStatement();
// preenche a lista de Tipo de Equipamentos
rs = stmt.executeQuery("select descricao from tipoequipamento order by descricao");
while(rs.next()){
cboTipoEquipamento.addItem(rs.getObject(1));
}
// Preenche a lista de Marcas
rs = stmt.executeQuery("select marca from marca order by marca");
while(rs.next()){
cboMarca.addItem(rs.getObject(1));
}
stmt.close();
} catch (Exception ex) {
Logger.getLogger(Listamarcas.class.getName()).log(Level.SEVERE, null, ex);
}
}