seancorfield / next-jdbc

A modern low-level Clojure wrapper for JDBC-based access to databases.
https://cljdoc.org/d/com.github.seancorfield/next.jdbc/
Eclipse Public License 1.0
755 stars 90 forks source link

Document how to set driver properties when using a connection pool #186

Closed holyjak closed 2 years ago

holyjak commented 2 years ago

For next-jdbc and jdbc.connection/->pool , it seems that neither the docstring nor the docs mention how to set properties on the underlying Jdbc driver, right? That is understandable since it will differ for each pool but still an example in the docs would be nice. I currently do this for Hikari:

(jdbc.connection/->pool com.zaxxer.hikari.HikariConfig
                            {:dbtype "postgres" :host "localhost", :port 5432, :username "ardoq", :password "ardoq"
                             :dataSourceProperties
                             (doto (java.util.Properties.)
                               (.putAll {"socketTimeout" "30"}))})

Not sure whether there is a nicer way... (java.data cannot convert a map to Properties, yet)

seancorfield commented 2 years ago

I had a look over the c3p0 docs and there doesn't appear to be an equivalent to this -- everything is just a configuration item for c3p0 itself and it does whatever is appropriate, as far as I can tell (and its source code is pretty impenetrable since a bunch of it is auto-generated from XML templates -- eek!).

I'll probably add the Properties stuff to java.data first and then just document how to use that in the HikariCP-specific docs in next.jdbc (and cut new releases).

It'll be a while before I get my next decent OSS window.

seancorfield commented 2 years ago

In 1.2.737

seancorfield commented 2 years ago

Note: this does not actually work -- it needs to be com.zaxxer.hikari.HikariDataSource (instead of HikariConfig). Someone just tripped over this in the docs so I'm fixing it.