Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
Can I overwrite a statement if autocommit is disabled?

Lets say I do have code like this:

let connection;
let preparedStatement;

connection = createConnectionSomehow();
connection.setAutoCommit(false);

preparedStatement = connection.prepareStatement(query1);
preparedStatement.executeUpdate();

preparedStatement = connection.prepareStatement(query2);
preparedStatement.executeUpdate();

connection.commit();

Will both queries been executed or will the second query overwrite the first one?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

In short - both queries will be executed as a single atomic operation when auto commit is false and you are only committing at the end. This will happen in the order you issues them usually but can depend on which database you are using.

That should be fairly easy to verify if you run the code commenting the operations or updating the same record with both queries.

about 4 years ago · Juan Pablo Isaza Relatório

0

Connection getConnection() throws SQLException {
Connection con = ... // create the connection
con.setAutoCommit(false);
return con;

}

setAutoCommit(false) call here so that callers of this method never have to worry about setting it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda