Olá, pessoal!
Estou com uma dificuldade em fazer uma verificação de cadastro.
Ele até verifica e mostra que existe, o problema é que quando nao existe ele nao faz nada!!!
private void btCadastrarActionPerformed(java.awt.event.ActionEvent evt) {
String mostraIng = tfIngrediente.getText();
String verificaIngrediente = "SELECT * FROM INGREDIENTE WHERE INGREDIENTE = '"+mostraIng+"'";
try {
AcessoFireBird firebird = new AcessoFireBird();
pstm = firebird.conectar().prepareStatement(verificaIngrediente);
rs = pstm.executeQuery();
if (rs.next()) {
if (rs.getString("ingrediente").equals(mostraIng)) {
JOptionPane.showMessageDialog(null, "Este ingrediente já está cadastrado!");
} else {
cadastrarIngrediente();
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
Se não existe ele nao vai para o else e executa o cadastrar.
Se alguem poder dar uma mãozinha, vou agradecer! =)
Muito obrigado.
