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

  • SEARCH
  • Home
  • 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 6589303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:09:24+00:00 2026-05-25T17:09:24+00:00

I am updating multiple records in database. Now whenever UI sends the list of

  • 0

I am updating multiple records in database. Now whenever UI sends the list of records to be updated, I have to just update those records in database. I am using JDBC template for that.

Earlier Case

Earlier what I was whenever I got records from UI, I just do

jdbcTemplate.batchUpdate(Query, List<object[]> params)

Whenever there was an exception, I used to rollback whole transaction.

(Updated : Is batchUpdate multi-threaded or faster than batch update in some way?)

Later Case

But later as requirement changed whenever there was exception. So, whenever there is some exception, I should know which records failed to update. So I had to sent the records back to UI in case of exception with a reason, why did they failed.

so I had to do something similar to this:

for(Record record : RecordList)
{
   try{
       jdbcTemplate.update(sql, Object[] param)
   }catch(Exception ex){
       record.setReason("Exception : "+ex.getMessage());
       continue;
   }
}

So am I doing this in right fashion, by using the loop?

If yes, can someone suggest me how to make it multi-threaded.
Or is there anything wrong in this case.
To be true, I was hesitating to use try catch block inside the loop 🙁 .

Please correct me, really need to learn a better way because I myself feel, there must be a better way , thanks.

  • 1 1 Answer
  • 0 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-25T17:09:24+00:00Added an answer on May 25, 2026 at 5:09 pm

    make all update-operation to a Collection Callable<>,
    send it to java.util.concurrent.ThreadPoolExecutor. the pool is multithreaded.

    make Callable:

    class UpdateTask implements Callable<Exception> {
      //constructor with jdbctemplate,sql,param goes here.
      @Override
        public Exception call() throws Exception {
            try{
                  jdbcTemplate.update(sql, Object[] param)
                }catch(Exception ex){
                       return ex;
               }
    
            return null;
        }
    

    invoke call:

    <T> List<Future<T>> java.util.concurrent.ExecutorService.invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple data sources inserting and updating to an oracle10g database. I also
I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
Subsonic 3.0 is updating multiple rows instead of just the one it's supposed to
Is there a way to have multiple delayed_job workers updating to the same table?
I need to add new records to my SQL database using C# and php.
I am in the midst of updating data in multiple tables. Currently I have
I'm using hadoop to update some records in a mysql db... The issue that
I have added multiple JProgressBar to TableColumn of JTable . I am updating all
I want to iterate over records in the database and update them. However since
I have multiple applications using log4j for their logging, each loading settings from separate

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.