title: How do I know if the prepared statements are cached?
body: <p>I am using Hikari with SQL Server 2016 and sqljdbc4-2.0.jar in the tomcat lib folder.</p>
  
  <p>My configuration for db resource is as follows:</p>
  
  <pre><code>&lt;Resource name="jdbc/SQLServerDS" auth="Container" type="javax.sql.DataSource"
                username="uname"
                password="pwd"
                driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
                url="jdbc:sqlserver://server:port;DatabaseName=dbName"
                maxActive="20"
                maxIdle="10"
                validationQuery="select 1" /&gt;
  </code></pre>
  
  <p>My Datasource configuration is as follows:</p>
  
  <pre><code>@Bean(name = "dataSource")
      public DataSource getDataSource() throws NamingException {
          HikariConfig config = new HikariConfig();
          config.setMaximumPoolSize(20);
          config.setDataSourceJNDI("java:comp/env/jdbc/SQLServerDS");
          config.addDataSourceProperty("cachePrepStmts", "true");
          config.addDataSourceProperty("prepStmtCacheSize", "250");
          config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
          config.addDataSourceProperty("useServerPrepStmts", "true");
          config.addDataSourceProperty("cacheResultSetMetadata", "true");
          config.addDataSourceProperty("useLocalSessionState", "true");
          config.addDataSourceProperty("cacheServerConfiguration", "true");
          config.addDataSourceProperty("elideSetAutoCommits", "true");
          config.addDataSourceProperty("maintainTimeStats", "false");
          return new TransactionAwareDataSourceProxy(
                  new LazyConnectionDataSourceProxy(new HikariDataSource(config)));
      }
  </code></pre>
  
  <p>How do I know if the preparedstatement caching is working for different connections?</p>
  
  <p>I am using spring container managed transactions with hibernate v4.3.10.Final.</p>
  
  <p>Also, for the caching to work, do I need to have second-level cache enabled?</p>