shruthi reddy
shruthi reddy

Reputation: 1

I have a one million records in my excel file or text file, i want to insert that data to database using multi threading concept in java

I already implemented this without threads concept, now to increase the performance i want to use multi threading concept, does this concept works here? Please suggest better ideas to implement this. I mean how to implement using Jdbc with multiple threads to insert the data from excel sheet to database.

Upvotes: 0

Views: 1462

Answers (1)

Zim-Zam O'Pootertoot
Zim-Zam O'Pootertoot

Reputation: 18148

See my answer to this question from awhile back - you'd use one thread to read in the data which you would put in an ArrayBlockingQueue (don't use a LinkedBlockingQueue or you might run out of heap space if the file reader is faster than the database writer), then use another thread to read data from the BlockingQueue and put it in your database. (There probably isn't any benefit to using multiple threads to write to the database, but if there's any preprocessing involved then you can use multiple threads for preprocessing and a single thread to write to the database)

Upvotes: 1

Related Questions