Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 783097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:29:33+00:00 2026-05-14T20:29:33+00:00

Suppose I have a table that contains valid data. I would like to modify

  • 0

Suppose I have a table that contains valid data. I would like to modify this data in some way, but I’d like to make sure that if any errors occur with the modification, the table isn’t changed and the method returns something to that effect.

For instance, (this is kind of a dumb example, but it illustrates the point so bear with me) suppose I want to edit all the entries in a “name” column so that they are properly capitalized. For some reason, I want either ALL of the names to have proper capitalization, or NONE of them to have proper capitalization (and the starting state of the table is that NONE of them do).

Is there an already-implemented way to run a batch update on the table and be assured that, if any one of the updates fails, all changes are rolled back and the table remains unchanged?

I can think of a few ways to do this by hand (though suggestions are welcomed), but it’d be nice if there was some method I could use that would function this way. I looked at the java.sql.statement.executeBatch() command, but I’m not convinced by the documentation that my table wouldn’t be changed if it failed in some manner.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:29:34+00:00Added an answer on May 14, 2026 at 8:29 pm

    I hit this one too when starting with JDBC – it seemed to fly in the face of what I understood about databases and ACID guarantees.

    Before you begin, be sure that your MySQL storage engine supports transactions. MyISAM doesn’t support transactions, but InnoDB does.

    Then be sure to disable JDBC autoCommit – Connection.setAutoCommit(false), or the JDBC will run each statement as a separate trasaction. The commit will be an all or nothing affair – there will be no partial changes.
    Then you run your various update statements, and finally call Connection.commit() to commit the transaction.

    See the Sun Tutorial for more details about JDBC transactions.

    Using a batch does not change the ACID guarantees – you’re either transacted or you’re not! – batching is more about collecting multiple statements together for improved performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose that I have a database table that contains information on cities across the
Suppose I have a table that contains a list of ids pointing to table
Suppose I have a table view, and I want to implement something like this:
Suppose the following scenario: I have a master database that contains lots of data,
Suppose I have table A with a field that can be either 1 or
Suppose I have two columns in a table that represents a graph, the first
Suppose I have a table, the first column is an identity. I thought that
Suppose I have an array that mimics a database table. Each array element represents
Lets suppose that I have a Category table with a column that holds the
Suppose I have employee and department table, employee has foreign key departmentID that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.