I have created some clojure function to access a database, as shown in the snippet below:
(defn get-dg [date]
(let [query (str "......")
]
(jdbc/with-connection db
(jdbc/with-query-results rows
[query date date date date]
(.debug log rows)
(if (not (seq rows))
nil
rows))))
)
Everything works fine. The query returns a result set which I can then process. Now, if I comment out (.debug log rows) I get this:
java.lang.RuntimeException: java.sql.SQLException: Closed Resultset: next
Any idea why?
Thanks
“rows” are lazy. And It’s seems that “(.debug log rows)” evaluated the “rows”. Just do it explicitly: