@Override
  public DataSource create(Configuration hdpConfig, int maxPoolSize) throws SQLException {
    String poolName = DataSourceProvider.getDataSourceName(hdpConfig);
    LOG.info("Creating Hikari connection pool for the MetaStore, maxPoolSize: {}, name: {}", maxPoolSize, poolName);

    String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig);
    String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig);
    String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig);

    Properties properties = replacePrefix(DataSourceProvider.getPrefixedProperties(hdpConfig, HIKARI));

    HikariConfig config;
    try {
      config = new HikariConfig(properties);
    } catch (Exception e) {
      throw new SQLException("Cannot create HikariCP configuration: ", e);
    }
    config.setMaximumPoolSize(maxPoolSize);
    config.setJdbcUrl(driverUrl);
    config.setUsername(user);
    config.setPassword(passwd);
    if (!StringUtils.isEmpty(poolName)) {
      config.setPoolName(poolName);
    }

    // It's kind of a waste to create a fixed size connection pool as same as the TxnHandler#connPool,
    // TxnHandler#connPoolMutex is mostly used for MutexAPI that is primarily designed to
    // provide coarse-grained mutex support to maintenance tasks running inside the Metastore,
    // add minimumIdle=2 and idleTimeout=10min(default, can be set by hikaricp.idleTimeout) to the pool,
    // so that the connection pool can retire the idle connection aggressively,
    // this will make Metastore more scalable especially if there is a leader in the warehouse.
    if ("mutex".equals(poolName)) {
      int minimumIdle = Integer.parseInt(hdpConfig.get(HIKARI + ".minimumIdle", "2"));
      config.setMinimumIdle(Math.min(maxPoolSize, minimumIdle));
    }

    DatabaseProduct dbProduct =  DatabaseProduct.determineDatabaseProduct(driverUrl, hdpConfig);

    String s = dbProduct.getPrepareTxnStmt();
    if (s!= null) {
      config.setConnectionInitSql(s);
    }

    Map<String, String> props = dbProduct.getDataSourceProperties();

    for ( Map.Entry<String, String> kv : props.entrySet()) {
      config.addDataSourceProperty(kv.getKey(), kv.getValue());
    }

    return new HikariDataSource(initMetrics(config));
  }
DataSourceProvider for the HikariCP connection pool.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/datasource/HikariCPDataSourceProvider.java