Skip to content

Instantly share code, notes, and snippets.

@jacoelho
Last active July 31, 2016 19:52
Show Gist options
  • Save jacoelho/1418fbf904e79ccd363a9a34a973b7a7 to your computer and use it in GitHub Desktop.
Save jacoelho/1418fbf904e79ccd363a9a34a973b7a7 to your computer and use it in GitHub Desktop.
(def db-config
{:classname "org.h2.Driver"
:subprotocol "h2"
:subname "mem:todo"
:user ""
:password ""})
(defn pool
[config]
(let [cpds
(doto
(ComboPooledDataSource.)
(.setDriverClass (:classname config))
(.setJdbcUrl (str "jdbc:" (:subprotocol config) ":" (:subname config)))
(.setUser (:user config))
(.setPassword (:password config))
(.setMaxPoolSize 6)
(.setMinPoolSize 1)
(.setInitialPoolSize 1))]
{:datasource cpds}))
(def pooled-db (delay (pool db-config)))
(defn db-connection [] @pooled-db)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment