Search code examples
javadatabasec3p0hikaricpflexy-pool

How I can use FlexyPool with HikariCPFactory?


I want measure metrics on my datasource comparing HikariCP and C3pO. I don’t understand how I can use FlexyPool in my project. I have Tomcat context.xml and HikariCP:

          <Resource name="jdbc/dictionaryDB"
            auth="Container"
            factory="com.zaxxer.hikari.HikariJNDIFactory"
            type="javax.sql.DataSource"
            driverClassName="org.postgresql.Driver"
            jdbcUrl="jdbc:postgresql://localhost:5432/deversdb"
            username="user"
            password="pass"
            maxActive="8"
            maxIdle="4"/>

Please help me, i’am very newbie in connection pooling theme. What I must to do with this https://github.com/vladmihalcea/flexy-pool/wiki/HikariCP-Configuration ?


Solution

  • Since you already have a DataSource that is provided via JNDI, you could try to use the Java EE installation mode.

    For this, you need a flexy-pool.properties configuration file on your classpath root, which must contain the following properties:

    flexy.pool.data.source.unique.name=some-unique-name
    flexy.pool.data.source.jndi.name=jdbc/dictionaryDB
    flexy.pool.metrics.reporter.jmx.auto.start=true
    

    As dependencies, you need:

    <dependency>
        <groupId>com.vladmihalcea.flexy-pool</groupId>
        <artifactId>flexy-java-ee</artifactId>
        <version>${flexy-pool.version}</version>
    </dependency>