diff --git a/README.md b/README.md index 3ab66dfc..f732a5f2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ There is nothing faster. There is nothing more correct. HikariCP is a "zero-ov com.zaxxer HikariCP - 1.3.4 + 1.3.5 compile ``` @@ -35,10 +35,13 @@ Using the excellent [JMH microbenchmark framework](http://openjdk.java.net/proje 2 Tomcat fails to complete *Statement Cycle* benchmark when "StatementFinalizer" feature is enabled.
3 Benchmark results run against 1.3.3
-#### What's wrong with other pools? +#### What's up with other pools? Not all pools are created equal. Read our [pool analysis](https://github.com/brettwooldridge/HikariCP/wiki/Pool-Analysis) here if you care to know the good, bad, and ugly. +#### You're [probably] doing it wrong. +AKA ["What you probably didn't know about connection pool sizing"](https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing). Read on to find out. + ------------------------------ #### Configuration (knobs, baby!) @@ -126,12 +129,12 @@ preferred if supported by the JDBC driver. *Default: true* :abc:``jdbcUrl``
This property is only used when the ``driverClassName`` property is used to wrap an old-school JDBC driver as a ``javax.sql.DataSource``. While JBDC URLs are popular, HikariCP does not -recommend using them. The *DataSource* implementation for your driver provides bean properties -for all the driver parameters that used to be specified in the JDBC URL. Before using the ``jdbcUrl`` -and ``driverClassName`` because that's the way you've always done it, consider using the more -modern and maintainable ``dataSourceClassName`` approach instead. Note that if this property -is used, you may still use *DataSource* properties to configure your driver and is in fact -recommended. *Default: none* +recommend using them. The *DataSource* implementation provided by your driver provides bean +properties for all the driver parameters that used to be specified in the JDBC URL. Before using +the ``jdbcUrl`` and ``driverClassName`` because that's the way you've always done it, consider +using the more modern and maintainable ``dataSourceClassName`` approach instead. Note that if +this property is used, you may still use *DataSource* properties to configure your driver and +is in fact recommended. *Default: none* :watch:``leakDetectionThreshold``
This property controls the amount of time that a connection can be out of the pool before a @@ -162,7 +165,7 @@ before timing out. *Default: 10* This property controls the minimum number of *idle connections* that HikariCP tries to maintain in the pool. If the idle connections dip below this value, HikariCP will make a best effort to add additional connections quickly and efficiently. However, for maximum performance and -responsiveness to spike demands, we recommend *not* setting this value and instead alloing +responsiveness to spike demands, we recommend *not* setting this value and instead allowing HikariCP to act as a *fixed size* connection pool. *Default: same as maximumPoolSize* :abc:``password``
@@ -272,6 +275,22 @@ ds.addDataSourceProperty("password", "51mp50n"); ``` The advantage of configuring via ``HikariConfig`` over ``HikariDataSource`` is that when using the ``HikariConfig`` we know at ``DataSource`` construction-time what the configuration is, so the pool can be initialized at that point. However, when using ``HikariDataSource`` alone, we don't know that you are *done* configuring the DataSource until ``getConnection()`` is called. In that case, ``getConnection()`` must perform an additional check to see if the pool has been initialized yet or not. The cost (albeit small) of this check is incurred on every invocation of ``getConnection()`` in that case. In summary, intialization by ``HikariConfig`` is ever so slightly more performant than initialization directly on the ``HikariDataSource`` -- not just at construction time but also at runtime. +### Popular DataSource Class Names +We recommended using ``dataSourceClassName`` instead of ``driverClassName``/``jdbcUrl``, as using the driver class requires HikariCP to wrap the driver with an internal *DataSource* class. Here is a list of JDBC *DataSource* classes for popular databases: + +| Database | Driver | *DataSource* class | +|:---------------- |:------------ |:-------------------| +| Apache Derby | Derby | org.apache.derby.jdbc.ClientDataSource | +| H2 | H2 | org.h2.jdbcx.JdbcDataSource | +| HSQLDB | HSQLDB | org.hsqldb.jdbc.JDBCDataSource | +| MariaDB & MySQL | MariaDB | org.mariadb.jdbc.MySQLDataSource | +| MySQL | Connector/J | com.mysql.jdbc.jdbc2.optional.MysqlDataSource | +| MS SQL Server | Microsoft | com.microsoft.sqlserver.jdbc.SQLServerDataSource | +| Oracle | Oracle | oracle.jdbc.pool.OracleDataSource | +| PostgreSQL | pgjdbc-ng | com.impossibl.postgres.jdbc.PGDataSource | +| PostgreSQL | PostgreSQL | org.postgresql.ds.PGSimpleDataSource | +| SyBase | jConnect | com.sybase.jdbcx.SybDataSource | + ### Play Framework Plugin Github user [autma](https://github.com/autma) has created a [plugin](https://github.com/autma/play-hikaricp-plugin) for the Play framework. Thanks! diff --git a/src/main/java/com/zaxxer/hikari/HikariPool.java b/src/main/java/com/zaxxer/hikari/HikariPool.java index 20bc3c3a..18850e0a 100644 --- a/src/main/java/com/zaxxer/hikari/HikariPool.java +++ b/src/main/java/com/zaxxer/hikari/HikariPool.java @@ -198,7 +198,8 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener } else { - LOGGER.debug("Connection returned to pool is broken, or the pool is shutting down. Closing connection."); + LOGGER.debug("Connection returned to pool {} is broken, or the pool is shutting down. Closing connection.", + configuration.getPoolName()); closeConnection(connectionProxy); } } @@ -357,7 +358,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener long now = System.currentTimeMillis(); if (now - lastConnectionFailureTime > 1000 || isDebug) { - LOGGER.warn("Connection attempt to database failed (not every attempt is logged): {}", e.getMessage(), (isDebug ? e : null)); + LOGGER.warn("Connection attempt to database {} failed (not every attempt is logged): {}", configuration.getPoolName(), e.getMessage(), (isDebug ? e : null)); } lastConnectionFailureTime = now; return false;