This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-13
Channels
- # announcements (18)
- # babashka (52)
- # beginners (47)
- # calva (45)
- # clj-kondo (31)
- # clojure (18)
- # clojure-brasil (2)
- # clojure-europe (3)
- # clojure-sweden (25)
- # clojurescript (19)
- # cursive (15)
- # datalevin (11)
- # defnpodcast (2)
- # duct (1)
- # editors (1)
- # emacs (6)
- # gratitude (1)
- # introduce-yourself (6)
- # jobs-discuss (11)
- # leiningen (3)
- # lsp (10)
- # luminus (2)
- # off-topic (4)
- # podcasts (2)
- # reitit (2)
- # shadow-cljs (10)
- # sql (9)
- # xtdb (4)
what is the recommended way to deal with connection problems? should I wrap my db calls in try and manually perform reconnects or does connection pools(libs) offer that automatically?
@roguas Use HikariCP (connection pooling). Always.
next.jdbc
supports it out of the box.
We used c3p0 at work for years and it was fine. We just switched to HikariCP and it was painless and it much better maintained, documented, and supported.
Create a connection pooled datasource at app startup. Pass it to every next.jdbc
call. End of story.
Hello
> What does this mean for your use of `next.jdbc`? In `plan`, `execute!`, and `execute-one!`, you can use `col = ANY(?)` in the SQL string and a single primitive array parameter, such as `(int-array [1 2 3 4])`. That means that in `next.jdbc.sql`’s functions that take a where clause (`find-by-keys`, `update!`, and `delete!`) you can specify `["col = ANY(?)" (int-array data)]` for what would be a `col IN (?,?,?,,,?)` where clause for other databases and require multiple values.
Is there an equivalent to this for SqlServer?
I found https://github.com/microsoft/mssql-jdbc/issues/972 but it was rejected.
Is there anything better than creating the (?,?,?,,,?)
section in the query?
Thanks in advance
Yea, you just use https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver15. Here is an example:
(defn select-objects-by-ids [conn]
(next.jdbc/execute!
conn
["select *
from sys.objects
where object_id in (
select id
from openjson(?) with (id int '$')
)"
(cheshire.core/generate-string [1 2 3])]))
@orlando No idea about SQL Server -- never used it -- but databases vary a huge amount and JDBC is a very minimal commonality.

Yea, you just use https://docs.microsoft.com/en-us/sql/t-sql/functions/openjson-transact-sql?view=sql-server-ver15. Here is an example:
(defn select-objects-by-ids [conn]
(next.jdbc/execute!
conn
["select *
from sys.objects
where object_id in (
select id
from openjson(?) with (id int '$')
)"
(cheshire.core/generate-string [1 2 3])]))