commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Xiaodan Zhou (Updated) (JIRA)" <>
Subject [jira] [Updated] (DBUTILS-83) Add "BatchUploader" (related to DBUTILS-78 but different)
Date Wed, 09 Nov 2011 17:03:51 GMT


Daniel Xiaodan Zhou updated DBUTILS-83:

> Add "BatchUploader" (related to DBUTILS-78 but different)
> ---------------------------------------------------------
>                 Key: DBUTILS-83
>                 URL:
>             Project: Commons DbUtils
>          Issue Type: New Feature
>    Affects Versions: Nightly Builds
>            Reporter: Daniel Xiaodan Zhou
>            Priority: Minor
>         Attachments:
> I have created a BatchUploader class in one of my project, and thought I might contribute
it to DbUtils.
> It is similar to DBUTILS-78, but is different. It is basically a "producer-consumer"
queue, where you application produce rows, and BatchUploader "consumes" the rows and write
them back to the database. DBUTILS-78 also uses multi-threading, but it doesn't have the "producer-consumer"
queue. So you could imagine cases where you add too many rows in a batch before run executeBatch()
and cause "Java Out of Memory". Also, BatchUploader only uses simple Thread class, so it's
more compatible to other Java libraries compared to using ExecutorService/Future.
> Here's how you use BatchUploader in you application:
> uploader = new BatchUploader(threadName, dbConnection, sqlStmt);
> uploader.start();
> while (...) {
>   uploader.put(...); //  here you put each row in the queue
> }
> uploader.accomplish();
> // some other code ...
> uploader.join(); // wait the uploader to finish before moving to the rest of the code.
> // continue running ...
> The code attached is directly copied from my project. If people here think it should
go into DbUtils, I can add more javadoc and remove the specific things that were used in my
project to make it more general.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message