glassfish
JDBC
HikariCP
payara

GlassFish/Payara での HikariCP の利用

手順

HikariCP に JNDI へのデータソース登録用の Factory クラスが用意されているので、glassfish-resources.xml に以下のように設定するだけで OK
※ 以下は MySQL 使用時の例

glassfish-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC
    "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
    "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>

    <custom-resource
        jndi-name="java:app/jdbc/sample"
        res-type="javax.sql.DataSource"
        factory-class="com.zaxxer.hikari.HikariJNDIFactory">
        <property name="dataSourceClassName" value="com.mysql.cj.jdbc.MysqlDataSource" />
        <property name="poolName" value="sample" />
        <property name="dataSource.url" value="jdbc:mysql://localhost:3306/sample" />
        <property name="dataSource.user" value="xxx" />
        <property name="dataSource.password" value="xxx" />
        <property name="dataSource.sslMode" value="DISABLED" />
        <property name="dataSource.characterEncoding" value="UTF-8" />
        <property name="dataSource.connectionCollation" value="utf8mb4_general_ci" />
        <property name="dataSource.serverTimezone" value="JST" />
        <property name="dataSource.cachePrepStmts" value="true" />
        <property name="dataSource.prepStmtCacheSize" value="250" />
        <property name="dataSource.prepStmtCacheSqlLimit" value="2048" />
        <property name="dataSource.useLocalSessionState" value="true" />
        <property name="dataSource.useLocalTransactionState" value="true" />
        <property name="dataSource.rewriteBatchedStatements" value="true" />
        <property name="dataSource.cacheResultSetMetadata" value="true" />
        <property name="dataSource.cacheServerConfiguration" value="true" />
        <property name="dataSource.elideSetAutoCommits" value="true" />
        <property name="dataSource.maintainTimeStats" value="false" />
        <property name="dataSource.noAccessToProcedureBodies" value="true" />
    </custom-resource>

</resources>

参照

JNDI DataSource Factory (Tomcat, etc.) · brettwooldridge/HikariCP Wiki