Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!