title: How to set custom connection properties on DataSource in Spring Boot 1.3.x with default Tomcat connection pool
body: <p>I need to set some specific Oracle JDBC connection properties in order to speed up batch <code>INSERT</code>s (<code>defaultBatchValue</code>) and mass <code>SELECT</code>s (<code>defaultRowPrefetch</code>).
  I got <a href="https://stackoverflow.com/questions/34789220/optimizing-jdbc-fetch-size-by-use-of-spring-boots-application-properties">suggestions</a> how to achieve this with DBCP (Thanks to M. Deinum) but I would like to:</p>
  
  <ul>
  <li>keep the default Tomcat jdbc connection pool</li>
  <li>keep application.yml for configuration</li>
  </ul>
  
  <p>I was thinking about a feature request to support <code>spring.datasource.custom_connection_properties</code> or similar in the future and because of this tried to pretent this was already possible. I did this by passing the relevant information while creating the DataSource and manipulated the creation of the DataSource like this:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Bean
  public DataSource dataSource() {
      DataSource ds = null;
  
      try {
          Field props = DataSourceBuilder.class.getDeclaredField("properties");
          props.setAccessible(true);
          DataSourceBuilder builder = DataSourceBuilder.create();
          Map&lt;String, String&gt; properties = (Map&lt;String, String&gt;) props.get(builder);
  
          properties.put("defaultRowPrefetch", "1000");
          properties.put("defaultBatchValue", "1000");
  
          ds = builder.url( "jdbc:oracle:thin:@xyz:1521:abc" ).username( "ihave" ).password( "wonttell" ).build();
  
          properties = (Map&lt;String, String&gt;) props.get(builder);
  
          log.debug("properties after: {}", properties);
      } ... leaving out the catches ...
      }
      log.debug("We are using this datasource: {}", ds);
      return ds;
  }
  </code></pre>
  
  <p>In the logs I can see that I am creating the correct DataSource:</p>
  
  <pre><code>2016-01-18 14:40:32.924 DEBUG 31204 --- [           main] d.a.e.a.c.config.DatabaseConfiguration   : We are using this datasource: org.apache.tomcat.jdbc.pool.DataSource@19f040ba{ConnectionPool[defaultAutoCommit=null; ...
  
  2016-01-18 14:40:32.919 DEBUG 31204 --- [           main] d.a.e.a.c.config.DatabaseConfiguration   : properties after: {password=wonttell, driverClassName=oracle.jdbc.OracleDriver, defaultRowPrefetch=1000, defaultBatchValue=1000, url=jdbc:oracle:thin:@xyz:1521:abc, username=ihave}
  </code></pre>
  
  <p>The actuator shows me that my code replaced the datasource:</p>
  
  <p><a href="https://i.stack.imgur.com/gulPH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gulPH.png" alt="enter image description here"></a></p>
  
  <p>But the settings are not activated, which I can see while profiling the application. The <code>defaultRowPrefetch</code> is still at <code>10</code> which causes my <code>SELECT</code>s to be much slower than they would be if <code>1000</code> was activated.</p>