Skip to content

Commit

Permalink
[fr33m0nk]: Updates ReadMe with both examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fr33m0nk committed Feb 8, 2023
1 parent 8f7a97a commit 3eb9c2a
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ Custom translations of properties can be added by extending the
```

### ClickHouse example
- [Official ClickHouse JDBC driver](https://github.com/ClickHouse/clickhouse-java)'s `ClickHouseDataSource` does not have a zero arity constructor.
`hikari-cp` can be used with [official ClickHouse driver](https://github.com/ClickHouse/clickhouse-java) in following two ways:
1. Using `:datasource` property:
- Official ClickHouse JDBC driver's `ClickHouseDataSource` does not have a zero arity constructor.
- This mandates creating `ClickHouseDataSource` separately and setting `:datasource` property in `datasource-options`
```clojure
(ns hikari-cp.example
Expand Down Expand Up @@ -246,6 +248,33 @@ Custom translations of properties can be added by extending the
(defonce datasource
(delay (make-datasource datasource-options)))

(defn -main
[& args]
(with-open [conn (jdbc/get-connection {:datasource @datasource})]
(let [rows (jdbc/execute! conn ["SELECT 0"])]
(println rows)))
(close-datasource @datasource))
```
2. Using `:jdbc-url` and `:driver-class-name` properties:
```clojure
(ns hikari-cp.example
(:require
[hikari-cp.core :refer :all]
[next.jdbc :as jdbc]))

(def datasource-options-2
{:jdbc-url "jdbc:ch://localhost:8123/test_db"
:username "username"
:password "password"
:driver-class-name "com.clickhouse.jdbc.ClickHouseDriver"
:connection-timeout 5000
:maximum-pool-size 20
:max-lifetime 300000
:pool-name "clickhouse-conn-pool"})

(defonce datasource
(delay (make-datasource datasource-options)))

(defn -main
[& args]
(with-open [conn (jdbc/get-connection {:datasource @datasource})]
Expand Down

0 comments on commit 3eb9c2a

Please sign in to comment.