Bom pessoal…estou com o seguinte problema…quero digitar um código em um textfiel e se existir o registro ele me retorne o nome em outro textfiel…eu fiz um código no focuslost do textfiel mas ele naum tá retornando nda…esse é o meu código…
private void BuscaBanco(java.awt.event.FocusEvent evt) {
int brinco = 0;
Conexao conexao = new Conexao();
try{
Connection con=conexao.conecta();
String sql = “Select nome from animal where brinco =?”;
PreparedStatement stmt=con.prepareStatement(sql);
stmt.setInt(0, brinco);
ResultSet rsAnimal = stmt.executeQuery(“Select nome from animal where brinco =?”);
while(rsAnimal.next()){
String animal = rsAnimal.getString(2);
if(animal !=null && tfanimal.getText().length()>0){
nomeAnimal.setText(animal);
}else{
JOptionPane.showMessageDialog(null,“Brinco Inválido”);
}
}
rsAnimal.close();
stmt.close();
}catch(SQLException e){}
onde está o erro?
desde já agradeço.
