title: fast way to insert into database using java
body: <p>I was curious about how fast we can execute MySQL query through a loop in Java and well it is taking extremely long time with the code I wrote. I am sure there is a faster way to do it. Here is the piece of code that is executing the query.</p>
  
  <pre><code>PreparedStatement ps=connection.prepareStatement("INSERT INTO books.author VALUES (?,?,?)");
  for (int i=0;i&lt;100000;i++)
  {
         ps.setString(1,test[i][0]);
         ps.setString(2,test[i][1]);
         ps.setString(3,test[i][2]);
         ps.addBatch();
  }
  int []p=ps.executeBatch();
  </code></pre>
  
  <p>Any help would be much appreciated. Thank you</p>