Banco de dados insere valores na tabela, mas retorna um erro

Pessoal, o meu banco está inserindo na tabela, mas retorna o seguinte erro.


 try {

            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String connectionUrl = "jdbc:sqlserver://localhost:1433;"
                    + "databaseName=teste;user=sa;password=123;";
            try {

                Connection con = DriverManager.getConnection(connectionUrl);

                // executar uma query
                Statement st = (Statement) con.createStatement();
                String mySelect = "Insert into tb_Pessoa(id_Pessoa,nome,telefone) values (4,'Felipe','9965909090')";
                ResultSet rs = st.executeQuery(mySelect);

ERRO:

com.microsoft.sqlserver.jdbc.SQLServerException: A instrução não retornou um conjunto de resultados.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:783)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:676)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:611)
at teste_banco.Conexao_Banco.conectar(Conexao_Banco.java:37)
at teste_banco.Main.main(Main.java:20)

tanto inserção, atualização ou remoção ele não retorna nenhuma informação.
Tanta usar o método execute se eu não me engano não retorna nada.

Bom dia.

Ao invez de chamar “executeQuery” chame “executeUpdate”.

Att,

1 curtida