title: Oracle JDBC Optimization : Enable PreparedStatement caching in a Spring boot Application
body: <p>I have a Spring Boot REST application that's connected to an Oracle database. We're using JDBC using JdbcTemplate. The Oracle database properties are obtained through these 3 <strong>application.properties</strong> settings:</p>
  
  <pre><code>spring.datasource.url
  spring.datasource.username
  spring.datasource.password
  </code></pre>
  
  <p>This application is using the HikariCP. From the HikariCP website, I came to know that this pool doesn't cache PreparedStatements because the JDBC driver is best setup to do that.</p>
  
  <p>Now, where and what would I specify to ensure these : </p>
  
  <ol>
  <li><p>That the Oracle JDBC Driver(ojdbc7.jar) caches PreparedStatements. Is there a way to customize the number of PreparedStatements that it can cache.</p></li>
  <li><p>From <a href="https://howtodoinjava.com/java/jdbc/best-practices-to-improve-jdbc-performance/" rel="noreferrer">https://howtodoinjava.com/java/jdbc/best-practices-to-improve-jdbc-performance/</a>, we see that</p>
  
  <blockquote>
    <p>Ensure that your database is set to the maximum packet size and that
    the driver matches that packet size. For fetching larger result sets,
    this reduces the number of total packets sent/received between the
    driver and server.</p>
  </blockquote></li>
  </ol>
  
  <p>In pursuance of the above, what are the steps required to </p>
  
  <ol>
  <li>find the Oracle DB Server packet size </li>
  <li>find if the Oracle DB Server is set to the maximum packet size</li>
  <li>find set the Oracle JDBC driver's(ojdbc8.jar) packet size.</li>
  </ol>
  
  <p>Any other (Oracle) JDBC performance optimization tip would be appreciated.</p>