Gostaria de uma ajuda com o meu codigo estou fazendo uma agenda com alguns dados no access pois é um aplicativo caseiro em fim! O incluir e o Buscar esta 100% agora a parte de editar não está rolando tipo que fazer o seguite tenho meu campo NOME , nome = Pedro e quer alterar este campo tipo nome = Pedro Martins mais não sei qual é o problema ele passa reto e não da erro nenhum mais não altera o cadastro se alguempoder me ajudar eu agradeço.
class AlterarCliente implements ActionListener {
public void actionPerformed(ActionEvent e) {
// Busca os valores dos campos
String nomeCliente = JDBCIde.this.cliAltNome.getText();
String enderecoCliente = JDBCIde.this.cliAltEndereco.getText();
String numeroCliente = JDBCIde.this.cliAltNumero.getText();
String complementoCliente = JDBCIde.this.cliAltComplemento
.getText();
String bairroCliente = JDBCIde.this.cliAltBairro.getText();
String cidadeCliente = JDBCIde.this.cliAltCidade.getText();
String estadoCliente = JDBCIde.this.cliAltEstado.getText();
String cepCliente = JDBCIde.this.cliAltCep.getText();
String diaCliente = JDBCIde.this.cliAltDia.getText();
String mesCliente = JDBCIde.this.cliAltMes.getText();
String anoCliente = JDBCIde.this.cliAltAno.getText();
String telefoneCliente = JDBCIde.this.cliAltTelefone.getText();
String celularCliente = JDBCIde.this.cliAltCelular.getText();
String msnCliente = JDBCIde.this.cliAltMsn.getText();
String emailCliente = JDBCIde.this.cliAltEmail.getText();
if ((nomeCliente.length() == 0) && (enderecoCliente.length() == 0)
&& (numeroCliente.length() == 0)
&& (complementoCliente.length() == 0)
&& (bairroCliente.length() == 0)
&& (cidadeCliente.length() == 0)
&& (estadoCliente.length() == 0)
&& (cepCliente.length() == 0) && (diaCliente.length() == 0)
&& (mesCliente.length() == 0) && (anoCliente.length() == 0)
&& (telefoneCliente.length() == 0)
&& (celularCliente.length() == 0)
&& (msnCliente.length() == 0)
&& (emailCliente.length() == 0)) {
JOptionPane.showMessageDialog(JDBCIde.this,
"Informe pelo menos um campo", "Erro na busca",
JOptionPane.ERROR_MESSAGE);
JDBCIde.this.cliAltNome.requestFocus();
return;
}
// Realiza a alterasao
String q = "UPDATE bd_cadastro SET";
System.out.println(nomeCliente + " - " + nomeCopia);
System.out.println(enderecoCliente + " - " + enderecoCopia);
System.out.println(numeroCliente + " - " + numeroCopia);
System.out.println(complementoCliente + " - " + complementoCopia);
System.out.println(bairroCliente + " - " + bairroCopia);
System.out.println(cidadeCliente + " - " + cidadeCopia);
System.out.println(estadoCliente + " - " + estadoCopia);
System.out.println(cepCliente + " - " + cepCopia);
System.out.println(diaCliente + " - " + diaCopia);
System.out.println(mesCliente + " - " + mesCopia);
System.out.println(anoCliente + " - " + anoCopia);
System.out.println(telefoneCliente + " - " + telefoneCopia);
System.out.println(celularCliente + " - " + celularCopia);
System.out.println(msnCliente + " - " + msnCopia);
System.out.println(emailCliente + " - " + emailCopia);
if (!nomeCliente.equals(nomeCopia)) {
q += " nome = '" + nomeCliente + "' ,endereco = " + "'"
+ enderecoCliente + "'" + ",numero = " + "'"
+ numeroCliente + "'" + ",complemento = " + "'"
+ complementoCliente + "'" + ",bairro = " + "'"
+ bairroCliente + "'" + ",cidade = " + "'"
+ cidadeCliente + "'" + ",estado = " + "'"
+ estadoCliente + "'" + ",cep = " + "'" + cepCliente
+ "'" + ",dia = " + "'" + diaCliente + "'" + ",mes = "
+ "'" + mesCliente + "'" + ",ano = " + "'" + anoCliente
+ "'" + ",telefone = " + "'" + telefoneCliente + "'"+
",celular = " + "'" + celularCliente + "'" +
",msn = " + "'" + msnCliente + "'" +",email = " + "'" + emailCliente + "'"
+" where nome = " + "" + nomeCopia + "";
System.out.println(q);
System.out.println(" \n Entrou nome");
}
// apartir da qui não fiz os outros pois se um rodar o resto é facil.
if (!enderecoCliente.equals(enderecoCopia)) {
q += "and endereco = " + "'" + enderecoCliente + "'"
+ " where " + "endereco =" + "'" + enderecoCopia + "'";
System.out.println("Entrou endereco");
}
if (!numeroCliente.equals(numeroCopia)) {
q += "and numero = " + "'" + numeroCliente + "'" + " where "
+ "numero =" + "'" + numeroCopia + "'";
System.out.println("Entrou numero");
}
if (!complementoCliente.equals(complementoCopia)) {
q += "and complemento = " + "'" + complementoCliente + "'"
+ " where " + "complemento =" + "'" + complementoCopia
+ "'";
System.out.println("Entrou complemento");
}
if (!bairroCliente.equals(bairroCopia)) {
q += "and bairro = " + "'" + bairroCliente + "'" + " where "
+ "bairro =" + "'" + bairroCopia + "'";
System.out.println("Entrou bairro");
}
if (!cidadeCliente.equals(cidadeCopia)) {
q += "and cidade = " + "'" + cidadeCliente + "'" + " where "
+ "cidade =" + "'" + cidadeCopia + "'";
System.out.println("Entrou cidade");
}
if (!estadoCliente.equals(estadoCopia)) {
q += "and estado = " + "'" + estadoCliente + "'" + " where "
+ "estado =" + "'" + estadoCopia + "'";
System.out.println("Entrou estado");
}
if (!cepCliente.equals(cepCopia)) {
q += "and cep = " + "'" + cepCliente + "'" + " where "
+ "cep =" + "'" + cepCopia + "'";
System.out.println("Entrou cep");
}
if (!diaCliente.equals(diaCopia)) {
q += "and dia = " + "'" + diaCliente + "'" + " where "
+ "dia =" + "'" + diaCopia + "'";
System.out.println("Entrou dia");
}
if (!mesCliente.equals(mesCopia)) {
q += "and mes = " + "'" + mesCliente + "'" + " where "
+ "mes =" + "'" + mesCopia + "'";
System.out.println("Entrou mes");
}
if (!anoCliente.equals(anoCopia)) {
q += "and ano = " + "'" + anoCliente + "'" + " where "
+ "ano =" + "'" + anoCopia + "'";
System.out.println("Entrou ano");
}
if (!telefoneCliente.equals(telefoneCopia)) {
q += "and telefone = " + "'" + telefoneCliente + "'"
+ " where " + "telefone =" + "'" + telefoneCopia + "'";
System.out.println("Entrou telefone");
}
if (!celularCliente.equals(celularCopia)) {
q += "and celular = " + "'" + celularCliente + "'" + " where "
+ "celular =" + "'" + celularCopia + "'";
System.out.println("Entrou celular");
}
if (!msnCliente.equals(msnCopia)) {
q += "and msn = " + "'" + msnCliente + "'" + " where "
+ "msn =" + "'" + msnCopia + "'";
System.out.println("Entrou msn");
}
if (!emailCliente.equals(emailCopia)) {
q += "and email = " + "'" + emailCliente + "'" + " where "
+ "email =" + "'" + emailCopia + "'";
System.out.println("Entrou email");
}
try {
JDBCIde.statement.executeUpdate(q);
JOptionPane.showMessageDialog(JDBCIde.this,
"Cliente Alterado com sucesso", "Sucesso",
JOptionPane.PLAIN_MESSAGE);
// Posiciona o cursor no campo Nome
} catch (SQLException ex) {
JOptionPane.showMessageDialog(JDBCIde.this,
"Erro na Alteração! Altere só um campo por vez!",
"Erro na Alteração", JOptionPane.ERROR_MESSAGE);
}
}
}// fim da class