gettin-started: validate HikariCP pool

This commit is contained in:
Jakub Holý 2021-09-29 09:25:16 +02:00 committed by GitHub
parent eddd940018
commit 22666d0d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -480,6 +480,7 @@ Some important notes regarding HikariCP:
* Authentication credentials must use `:username` (if you are using c3p0 or regular, non-pooled, connections, then the db-spec hash map must contain `:user`).
* When using `:dbtype "jtds"`, you must specify `:connectionTestQuery "SELECT 1"` (or some other query to verify the health of a connection) because the jTDS JDBC driver does not implement `.isValid()` so HikariCP requires a specific test query instead (c3p0 does not rely on this method so it works with jTDS without needing `:preferredTestQuery`).
* When using PostgreSQL, and trying to set a default `:schema` via HikariCP, you will need to specify `:connectionInitSql "COMMIT;"` until [this HikariCP issue](https://github.com/brettwooldridge/HikariCP/issues/1369) is addressed.
* The way `->pool` constructs the data source, it will not be initialized at once and thus will not fail if the database is unreachable etc. To make sure that you initialize the pool and check connectivity, call `.getConnection` on it, for example like this: `(with-open [_ (.getConnection ds)])`
You will generally want to create the connection pooled datasource at the start of your program (and close it before you exit, although that's not really important since it'll be cleaned up when the JVM shuts down):