title: Spring jdbc template executing batch updates has bad performance
body: <p>I have a simple java swing application which interacts with a sqlite database through the spring JdbcTemplate. The problem appears when trying to dump an excel document to one table in the database, the <code>batchUpdate</code> methods takes a lot of time, around 40 secs for 300 excel rows. My configuration is this</p>
  
  <p>The DAO class</p>
  
  <pre><code>public int[] addAll(List&lt;Pedido&gt; p) {
  
      int[] a = jdbcTemplate.batchUpdate("Insert into producto values(?,?,?)", new BatchPreparedStatementSetter() {
  
          @Override
          public void setValues(PreparedStatement ps, int i) throws SQLException {
  
              Pedido ped = p.get(i);
              ps.setString(1, ped.getCodigo());
              ps.setDouble(2, ped.getPrecio());
              ps.setString(3, ped.getNombre());
  
          }
  
          @Override
          public int getBatchSize() {
              return p.size();
          }
      });
      return a;
  
  }
  </code></pre>
  
  <p>My configuration file</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
            "http://www.springframework.org/dtd/spring-beans.dtd"&gt;
  &lt;beans&gt;
      &lt;bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
                destroy-method="close"&gt;
          &lt;property name="driverClassName" value="org.sqlite.JDBC" /&gt;
          &lt;property name="url" value="jdbc:sqlite:toruso.sqlite" /&gt;
          &lt;property name="initialSize" value="1" /&gt;        
      &lt;/bean&gt;
      &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
          &lt;constructor-arg ref="dataSource" /&gt;
      &lt;/bean&gt;        
      &lt;bean id="pedidoDAO" class="toruso.model.DAO.PedidoDAOImplementation"&gt;
          &lt;property name="jdbcTemplate" &gt;
              &lt;ref local="jdbcTemplate"/&gt;
          &lt;/property&gt; 
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My Spring loader class</p>
  
  <pre><code>public class MainFrame extends javax.swing.JFrame {
  
      private ClassPathXmlApplicationContext springContext;
      PedidoDAO pedidoDao;
  
      public MainFrame() {
          initComponents();
          this.initSpringContainer();
      }
  
      public void initSpringContainer() {
          String[] contextPaths = new String[]{"configuration/appConf.xml"};
          springContext = new ClassPathXmlApplicationContext(contextPaths);
          BeanFactory factory = this.springContext;
          this.pedidoDao = (PedidoDAO) factory.getBean("pedidoDAO");
      }
  </code></pre>