Last active
July 31, 2016 19:52
-
-
Save jacoelho/1418fbf904e79ccd363a9a34a973b7a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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