Batch insert in JDBC taking long time
<p>I tried to batch insert 10K record by jdbc connection in MSSQL, it took around 18 to 20 secs to bulk insert. I want to insert in less than 3 seconds. Is there any way to insert quickly.</p>

<p><strong>My code given below</strong></p>

<pre><code>public void BatchInsert() {
    PreparedStatement pStmnt = null;
  try {
     final int batchSize = 1000;
     int count = 0;
     Connection con = createConnection();
     long end = System.currentTimeMillis();
     System.out.println("connection creation time :: " + (end - start));
     start = System.currentTimeMillis();
     pStmnt = con.prepareStatement("insert into testtable values(?)");
     for (int i = 1; i &lt;= 10000; i++) {
        pStmnt.setInt(1, i);
        pStmnt.addBatch();

       if (++count % batchSize == 0) {
          pStmnt.executeBatch();
       }
     }
     pStmnt.executeBatch(); // insert remaining records
     end = System.currentTimeMillis();
     System.out.println("total insert time :: " + (end - start));
 } catch (SQLException e) {
     e.printStackTrace();
 } finally {
     try {
       pStmnt.close();
     } catch (SQLException e) {
       e.printStackTrace();
     }
 }
    }
</code></pre>

<p>Thanks in advance for yr help.</p>