-
Notifications
You must be signed in to change notification settings - Fork 0
/
datasources.clj
47 lines (35 loc) · 1.47 KB
/
datasources.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(ns taoclj.foundation.datasources
(:import [com.zaxxer.hikari HikariDataSource]
[com.impossibl.postgres.jdbc PGDataSource]))
(defn create-datasource [config]
(doto (PGDataSource.)
(.setHost (:host config))
(.setPort (:port config))
(.setDatabase (:database config))
(.setUser (:username config))
(.setPassword (:password config))
; (.setSSL (or (:ssl config) false))
))
;; (create-datasource
;; {:host "localhost"
;; :port 5432
;; :database "foundation_tests"
;; :username "foundation_tests_user"
;; :password "password"
;; })
(defn create-pooled-datasource [config]
(doto (HikariDataSource.)
(.setDataSourceClassName "com.impossibl.postgres.jdbc.PGDataSource")
(.addDataSourceProperty "Host" (:host config))
(.addDataSourceProperty "Port" (:port config))
(.addDataSourceProperty "Database" (:database config))
(.addDataSourceProperty "User" (:username config))
(.addDataSourceProperty "Password" (:password config))
;; (.addDataSourceProperty "??" (or (:secure-connection config) false))
(.setConnectionTimeout 5000)
(.setMaximumPoolSize 3)
;(.addDataSourceProperty "cachePrepStmts", "true");
;(.addDataSourceProperty "prepStmtCacheSize", "250");
;(.addDataSourceProperty "prepStmtCacheSqlLimit", "2048");
;(.addDataSourceProperty "useServerPrepStmts", "true");
))