Announcement Announcement Module
Collapse
No announcement yet.
Bulk Insert with Spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bulk Insert with Spring

    Hello,
    I have an application that uses SQL Server and does the following,
    1. Get data from the user in form of xml file, which is converted into java beans.
    the size of the xml is around 1 GB.
    2. Do some validations on the records.
    3. Insert the validated records in the database.
    4. Insert the error logs in the database.
    5. Currently application is validating a single record and then inserting in the database, till the end. Thus very slow.

    We would like to introduce some kind of batch processing and do the following
    1. Get data from the user in form of xml file, which is converted into java beans.
    2. Do some validations on the records on the batch size say 1000.
    3. create a update/insert query string for both correct and incorrect records.
    like insert into ....;insert into ...; or a csv in memory.
    4. Call bulk insert to insert the records
    5. commit.

    I would like to know if there is any way I can call SQL Server Bulk insert command directly from my java code, which used JDBCTemplate.
    Or is there any better way to accomplish this.

    Thanks much in advance.

    diana.

  • #2
    BatchSqlUpdate allows you to insert batches of data. It requires that your JDBC driver supports batching. If will still run, but won't give you any performance improvement.

    Comment

    Working...
    X