File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,9 @@ Custom translations of properties can be added by extending the
215
215
```
216
216
217
217
### ClickHouse example
218
- - [ Official ClickHouse JDBC driver] ( https://github.com/ClickHouse/clickhouse-java ) 's ` ClickHouseDataSource ` does not have a zero arity constructor.
218
+ ` hikari-cp ` can be used with [ official ClickHouse driver] ( https://github.com/ClickHouse/clickhouse-java ) in following two ways:
219
+ 1 . Using ` :datasource ` property:
220
+ - Official ClickHouse JDBC driver's ` ClickHouseDataSource ` does not have a zero arity constructor.
219
221
- This mandates creating ` ClickHouseDataSource ` separately and setting ` :datasource ` property in ` datasource-options `
220
222
``` clojure
221
223
(ns hikari-cp.example
@@ -246,6 +248,33 @@ Custom translations of properties can be added by extending the
246
248
(defonce datasource
247
249
(delay (make-datasource datasource-options)))
248
250
251
+ (defn -main
252
+ [& args]
253
+ (with-open [conn (jdbc/get-connection {:datasource @datasource})]
254
+ (let [rows (jdbc/execute! conn [" SELECT 0" ])]
255
+ (println rows)))
256
+ (close-datasource @datasource))
257
+ ```
258
+ 2 . Using ` :jdbc-url ` and ` :driver-class-name ` properties:
259
+ ``` clojure
260
+ (ns hikari-cp.example
261
+ (:require
262
+ [hikari-cp.core :refer :all ]
263
+ [next.jdbc :as jdbc]))
264
+
265
+ (def datasource-options-2
266
+ {:jdbc-url " jdbc:ch://localhost:8123/test_db"
267
+ :username " username"
268
+ :password " password"
269
+ :driver-class-name " com.clickhouse.jdbc.ClickHouseDriver"
270
+ :connection-timeout 5000
271
+ :maximum-pool-size 20
272
+ :max-lifetime 300000
273
+ :pool-name " clickhouse-conn-pool" })
274
+
275
+ (defonce datasource
276
+ (delay (make-datasource datasource-options)))
277
+
249
278
(defn -main
250
279
[& args]
251
280
(with-open [conn (jdbc/get-connection {:datasource @datasource})]
You can’t perform that action at this time.
0 commit comments