Skip to content

Commit 3eb9c2a

Browse files
committed
[fr33m0nk]: Updates ReadMe with both examples
1 parent 8f7a97a commit 3eb9c2a

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ Custom translations of properties can be added by extending the
215215
```
216216

217217
### 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.
219221
- This mandates creating `ClickHouseDataSource` separately and setting `:datasource` property in `datasource-options`
220222
```clojure
221223
(ns hikari-cp.example
@@ -246,6 +248,33 @@ Custom translations of properties can be added by extending the
246248
(defonce datasource
247249
(delay (make-datasource datasource-options)))
248250

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+
249278
(defn -main
250279
[& args]
251280
(with-open [conn (jdbc/get-connection {:datasource @datasource})]

0 commit comments

Comments
 (0)