Ola,
Eu tenho uma tela onde o usuario digita um nome para pesquisa e aperta enter se tiverem outros nomes iguais ao que o usuario digitou é criada uma tabela com todos estes nomes.
Eu estou tentando fazer o seguinte:criar um evento para que todos os itens que tiverem naquela linha que eu selecionei da tabela passem para os textfields da tela.
Meu código é o seguinte:
[code]table.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
int viewRow = table.getSelectedRow();
if (viewRow < 0) {
System.out.println(“Tabela vazia!”);
} else {
try{
resultado=comando.executeQuery(“select Id,cpf,num_carne,nome from aluno where nome=’”+table.getModel().getValueAt(table.getSelectedRow(),0)+"’ and cpf=’"+table.getModel().getValueAt(table.getSelectedRow(),1)+"’");
if(resultado.next())
{
txtRC.setText(resultado.getString(1));
txtCPF.setText(resultado.getString(2));
txtNome.setText(resultado.getString(4));
txtCarne.setText(resultado.getString(3));
}
}
catch(SQLException er)
{
er.printStackTrace();
}
}
}
}
);[/code]
não esta entrando no if(resultado.next())
=(
alguém poderia me ajudar a encontrar o erro?
Obrigada