@@ -106,7 +106,10 @@ Custom translations of properties can be added by extending the
106106``` clojure
107107(ns hikari-cp.example
108108 (:require [hikari-cp.core :refer :all ]
109- [clojure.java.jdbc :as jdbc]))
109+ ; ; with clojure.java.jdbc:
110+ [clojure.java.jdbc :as jdbc]
111+ ; ; or with next.jdbc:
112+ [next.jdbc :as nj]))
110113
111114(def datasource-options {:allow-pool-suspension false
112115 :auto-commit true
@@ -129,29 +132,49 @@ Custom translations of properties can be added by extending the
129132(defonce datasource
130133 (delay (make-datasource datasource-options)))
131134
135+ ; ; clojure.java.jdbc:
132136(defn -main [& args]
133137 (jdbc/with-db-connection [conn {:datasource @datasource}]
134138 (let [rows (jdbc/query conn " SELECT 0" )]
135139 (println rows)
136140 (println (is-running? @datasource))))
137141 (close-datasource @datasource)
138142 (println (is-closed? @datasource)))
143+
144+ ; ; next.jdbc:
145+ (defn -main [& args]
146+ (with-open [conn (nj/get-connection @datasource)]
147+ (let [rows (nj/execute! conn [" SELECT 0" ])]
148+ (println rows)
149+ (println (is-running? @datasource))))
150+ (close-datasource @datasource)
151+ (println (is-closed? @datasource)))
139152```
140153### Neo4j
141154
142155``` clojure
143156(ns hikari-cp.example
144157 (:require [hikari-cp.core :refer :all ]
145- [clojure.java.jdbc :as jdbc]))
158+ ; ; with clojure.java.jdbc:
159+ [clojure.java.jdbc :as jdbc]
160+ ; ; or with next.jdbc:
161+ [next.jdbc :as nj]))
146162
147163(def datasource-options {:jdbc-url " jdbc:neo4j:bolt://host:port/?username=neo4j&password=xxxx&debug=true" })
148164
149165(defonce datasource
150166 (delay (make-datasource datasource-options)))
151167
168+ ; ; clojure.java.jdbc:
152169(defn -main [& args]
153170 (jdbc/with-db-connection [conn {:datasource @datasource}]
154171 (let [rows (jdbc/query conn [" MATCH (n:Foo) WHERE n.name = ? RETURN n" " john" ])]
172+ (println rows))))
173+
174+ ; ; next.jdbc:
175+ (defn -main [& args]
176+ (with-open [conn (nj/get-connection @datasource)]
177+ (let [rows (nj/execute! conn [" MATCH (n:Foo) WHERE n.name = ? RETURN n" " john" ])]
155178 (println rows)))
156179 (close-datasource @datasource))
157180```
@@ -167,7 +190,10 @@ Custom translations of properties can be added by extending the
167190``` clojure
168191(ns hikari-cp.example
169192 (:require [hikari-cp.core :refer :all ]
170- [clojure.java.jdbc :as jdbc]))
193+ ; ; with clojure.java.jdbc:
194+ [clojure.java.jdbc :as jdbc]
195+ ; ; or with next.jdbc:
196+ [next.jdbc :as nj]))
171197
172198(def datasource-options {:username " username"
173199 :password " password"
@@ -180,19 +206,30 @@ Custom translations of properties can be added by extending the
180206(defonce datasource
181207 (delay (make-datasource datasource-options)))
182208
209+ ; ; clojure.java.jdbc:
183210(defn -main [& args]
184211 (jdbc/with-db-connection [conn {:datasource @datasource}]
185212 (let [rows (jdbc/query conn " SELECT 0 FROM dual" )]
186213 (println rows)))
187214 (close-datasource @datasource))
215+
216+ ; ; next.jdbc:
217+ (defn -main [& args]
218+ (with-open [conn (nj/get-connection @datasource)]
219+ (let [rows (nj/execute! conn [" SELECT 0 FROM dual" ])]
220+ (println rows)))
221+ (close-datasource @datasource))
188222```
189223
190224### Sybase example
191225
192226``` clojure
193227(ns hikari-cp.example
194228 (:require [hikari-cp.core :refer :all ]
195- [clojure.java.jdbc :as jdbc]))
229+ ; ; with clojure.java.jdbc:
230+ [clojure.java.jdbc :as jdbc]
231+ ; ; or with next.jdbc:
232+ [next.jdbc :as nj]))
196233
197234(def datasource-options {:username " username"
198235 :password " password"
@@ -209,11 +246,19 @@ Custom translations of properties can be added by extending the
209246(defonce datasource
210247 (delay (make-datasource datasource-options)))
211248
249+ ; ; clojure.java.jdbc:
212250(defn -main [& args]
213251 (jdbc/with-db-connection [conn {:datasource @datasource}]
214252 (let [rows (jdbc/query conn " SELECT 0" )]
215253 (println rows)))
216254 (close-datasource @datasource))
255+
256+ ; ; next.jdbc:
257+ (defn -main [& args]
258+ (with-open [conn (nj/get-connection @datasource)]
259+ (let [rows (nj/execute! conn [" SELECT 0" ])]
260+ (println rows)))
261+ (close-datasource @datasource))
217262```
218263
219264### SQLite example
0 commit comments