title: Connection Pool - How to find that a CallableStatement uses connection pool (specifically HikariCP)? SQL Profiler or PerfMon counters?
body: <p>How to set up a profiler trace to find that my CallableStatement uses connection pool?</p>
  <p>I set a trace to capture Audit:Login , Audit:Logout, RPC:Completed. But all I see is <em>1-Non-Pooled</em> (image below). Is there any configuration in Hikari/JDBC driver to get the pool to work? I would expect my second call to the service be <em>2-Pooled</em> in profiler.</p>
  <p>Hikari configuration (I used both SQLServerDataSource and SQLServerConnectionPoolDataSource for datasourceclassname, both same result):</p>
  <pre class="lang-java prettyprint-override"><code>public HikariDataSource createHikariDataSource()  {
      HikariDataSource dbDatasource = new HikariDataSource();
      dbDatasource.setDataSourceClassName(&quot;com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSource&quot;);
      dbDatasource.addDataSourceProperty(&quot;databaseName&quot;, &quot;tempdb&quot;);
      dbDatasource.setPoolName(&quot;myJDBCTestConnectionPool&quot;);
      dbDatasource.setUsername(&quot;someuser&quot;);
      dbDatasource.setPassword(&quot;totallysafepassword&quot;);
      dbDatasource.setMinimumIdle(5);
      dbDatasource.setMaximumPoolSize(10);
      dbDatasource.setConnectionTimeout(300);
      dbDatasource.setIdleTimeout(1000);
      dbDatasource.setMaxLifetime(1000);
      return dbDatasource;
  }
  </code></pre>
  <p>Proc execution code (redacted)</p>
  <pre class="lang-java prettyprint-override"><code>public void execMyProc() {
      HikariDataSource hkds = createHikariDataSource();
      Connection conn = hkds.getConnection();
      CallableStatement stmt3 = conn.prepareCall({? = CALL dbo.connectionpooltest @InputParam1=?});
      stmt3.registerOutParameter(1,Types.INTEGER);
      stmt3.setInt(2,1);
      ResultSet rs1 = stmt3.executeQuery();
          rs1.close();
      conn.close();
  }
  </code></pre>
  <p>HikariCP and mssql-jdbc maven pom.xml entries</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
      &lt;groupId&gt;com.zaxxer&lt;/groupId&gt;
      &lt;artifactId&gt;HikariCP&lt;/artifactId&gt;
      &lt;version&gt;3.4.5&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
      &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
      &lt;version&gt;8.4.0.jre8&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>SQL Code</p>
  <pre class="lang-sql prettyprint-override"><code>use tempdb;
  go
  create or alter proc connectionpooltest (@InputParam1 int)
  as
  begin
      return @InputParam1;
  end;
  go
  </code></pre>
  <p>Profiler screenshot:</p>
  <p><a href="https://i.stack.imgur.com/VUlOt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VUlOt.png" alt="profiler" /></a></p>
  <p>Java Version : 1.8.281 (Language level 11 or 8)<br />
  SQL Server 2017 Developer Edition (same behavior on 2014 and 2019)</p>
  <p>Is there anyway to reliably say that my HikariCP configuration is using a pool? How do I find it using profiler/prefmon/other tools?</p>