Boa noite a todos,
Estou criando um pequeno sistema em Java, e após fazer um INSERT o banco de dados (postgresql) esta retornando a seguinte mensagem de exceção:
[color=darkred]Exception in thread “AWT-EventQueue-0” java.lang.RuntimeException: org.postgresql.util.PSQLException: Nenhum resultado foi retornado pela consulta.[/color]
Eis o código que gera o erro:
public void Gravar(Cliente cli) throws SQLException {
String sql = "INSERT INTO cliente (codigo, nome, endereco, cidade, estado, telefone, cpf) VALUES (DEFAULT,?,?,?,?,?,?)";
try{
PreparedStatement stmt = conexao.prepareStatement(sql);
stmt.setString(1, cli.getNome());
stmt.setString(2, cli.getEndereco());
stmt.setString(3, cli.getCidade());
stmt.setInt(4, cli.getEstado());
stmt.setString(5, cli.getTelefone());
stmt.setString(6, cli.getCpf());
stmt.executeQuery();
stmt.close();
conexao.close();
}
catch(SQLException e){
throw new RuntimeException(e);
}
}
Abaixo a tabela Cliente:
CREATE TABLE Cliente (
codigo serial NOT NULL,
nome character varying(30) NOT NULL,
endereco character varying(35) NOT NULL,
cidade character varying(35) NOT NULL,
estado integer NOT NULL,
telefone character varying(10),
cpf character varying(11),
CONSTRAINT cli_pkey PRIMARY KEY (codigo)
);
Grato a quem possa ajudar!!