Liking cljdoc? Tell your friends :D


Fast, simple, reliable. HikariCP is a "zero-overhead" production ready JDBC connection pool implementation for clojure.jdbc.



[clojure.jdbc/clojure.jdbc-hikari "0.3.3"]


compile "clojure.jdbc:clojure.jdbc-hikari:0.3.3"


only targets to java8. If you want use the java6-7 version of hikari-cp, you should setup all the dependencies manually.

Basic Usage

In order to use a connection pool, you should convert your plain dbspec into a datasource-dbspec using the helper function provided in each extension.

Example using DBCP connection pool
;; Import the desired implementation
(require '[jdbc.pool.dbcp :as pool])

;; Convert the standard dbspec to an other dbspec with `:datasource` key
(def dbspec (pool/make-datasource-spec {:database-name "test"
                                        :adapter :postgresql}))

Configuration options

HikariCP comes with "good" defaults that should work in majority standard environments, but obviously, it exposes set of options for customize it:

Table 1. Specific generic options of HikariCP


This property controls the default auto-commit behavior of connections returned from the pool. It is a boolean value. (default true)


This property controls whether Connections obtained from the pool are in read-only mode by default. (default `false)


This property controls the maximum number of milliseconds that a client will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a SQLException will be thrown. 100ms is the minimum value. (default 10000)


This property controls the maximum amount of time (in milliseconds) that a connection is allowed to sit idle in the pool. (default 60000)


This property controls the maximum lifetime of a connection in the pool. A value of 0 indicates no maximum lifetime (infinite lifetime). (default 1800000)


This property controls the minimum number of idle connections that HikariCP tries to maintain in the pool. (default 10)


This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend. (default 10)


This property sets the database adapter. Please check Adapters and corresponding datasource class names for the full list of supported adapters and their datasource class names. (this parameter is mandatory)


This property sets the default authentication username used when obtaining Connections from the underlying driver. (default nil)


This property sets the default authentication password used when obtaining Connections from the underlying driver. (default nil)

HikariCP, unlike other datasource implementations, requires to setup explicitly that adapter should be used. This is a list of supported adapters:

Table 2. List of adapters supported by HikariCP
AdapterDatasource class name


























Examples using HikariCP with h2 adapter.
(def dbspec
  (-> {:adapter :h2
       :url "jdbc:h2:/tmp/test"}
Example using HikariCP with postgresql adapter.
;; Convert the standard dbspec to an other dbspec with `:datasource` key
(def dbspec
  (-> {:database-name "test"
       :username "foo"
       :password "secret"
       :server-name "localhost"
       :port-number 5432
       :adapter :postgresql}

additional notes

Since clojure.jdbc 0.4.0-beta1, packages like this is not the recommended way to setup the connection pool. It provides the basic setup. If you want more controll and access to all options, consider using the dbcp directly as documented in

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close