The program I'm doing needs to delete users from the database!
In the code I determine:
Menu:
static private void Excluir(Connection con) throws SQLException
{
String cpf;
Scanner s = new Scanner(System.in);
Cliente cli = new Cliente();
System.out.println("Informe o CPF a ser Excluido:");
cli.cpf = s.next();
System.out.println();
cli.ExcluirPess(cli, con);
}
In the client class I determine:
public void ExcluirPess(Cliente cli, Connection con) throws SQLException {
String sql = "delete from Cliente where CPF_cliente = ?";
PreparedStatement stmt = con.prepareStatement(sql);
stmt.setString(1, cli.getCpf());
stmt.executeUpdate();
stmt.close();
}
I cleaned up as they demonstrated, but exclusion is not yet done! Does the fact that the PK CPF_cliente
in% FK
Endereco
Telefone
, interfere with deletion?