[RESOLVIDO]UpdateDAO

1 resposta
bacoco

Olá tenho o seguinte codigo para realizar update na minha tabela

public void altera(Funcionario funcionario){
        String sql = "update funcionario set idgestor = ?,"
                + "matricula = ?,nome = ?,senha = ?,email = ? "
                + "where idfuncionario = ?";
        try{
            PreparedStatement stmt = connection.prepareStatement(sql);
            stmt.setInt(1, funcionario.getIdGestor());
            stmt.setString(2, funcionario.getMatricula());
            stmt.setString(3, funcionario.getNome());
            stmt.setString(4, funcionario.getSenha());
            stmt.setString(5, funcionario.getEmail());
            stmt.setInt(6, funcionario.getIdFuncionario());
            
            stmt.execute();
            stmt.close();
            
        }catch (SQLException e) {
            throw new RuntimeException(e);
        }            
    }
Porém estou tendo o seguinte erro:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'funcionario set idgestor = 1,matricula = 'F8050628',nome = 'Ricardo Aparecido Pe' at line 1
Para conferir fui debugando e pelo Watch os valores estão corretos
funcionario.getIdGestor()	Integer	#2419	
value	int	1	
funcionario.getMatricula()	String	"F8050628"	
funcionario.getNome()	String	"Ricardo Aparecido Pereira"	
funcionario.getSenha()	String	"123456"	
funcionario.getEmail()	String	"[email removido]"	
funcionario.getIdFuncionario()	Integer	#2423	
value	int	17

Não entendo porque no Watch acuso o NOME como "Ricardo Aparecido Pereira" e na hora de mandar para o SQL está enviando 'Ricardo Aparecido Pe'...
É algo errado na construção do metodo?
O banco é MySQL

@Edit
Arrumei era um erro na SQL executada

1 Resposta

kadu.m.lino

desconsidera então o que eu tinha enviado! rs vlws

Criado 9 de janeiro de 2013
Ultima resposta 9 de jan. de 2013
Respostas 1
Participantes 2