You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@empire-db.apache.org by Christopher Richmond <cr...@referentia.com> on 2012/08/30 04:50:48 UTC

Batch inserts

With pure JDBC I can do a PreparedStamement(ps) with batches for inserting
large numbers of rows(millions) with my embedded H2 database.  This works
fine(along with setting autocommit OFF on my connection)
        int count = 0;

        for(int x = 1; x <= totalRows; x++){


          for(<each item of data I have, up to millions>){
            pst.setInt(colIndex, rowIndex);
          }

          pst.addBatch();
          if(++count % batchSize == 0) {
            pst.executeBatch();   //execute batches at specified invervals
(batchSize)

          }

        }


        pst.executeBatch(); // insert remaining records

        pst.close();

but I am now trying to use EmpireDB and it is unclear if I can do batch
inserts against the database usinge the EmpireDB api.  Is this possible and
is there sample code for how to configure or execute against the API do
this?

In summary, I want batch insertion for large sets of data(millions of
rows), executing batches of inserts at regular intervals like I was doing
with pure JDBC above.

Thanks,
Chris