sql

ag 2023-10-26T22:32:42.889189Z

I need to manage connection pooling for CockroachDB. As I don't have much experience with DB related stuff, could someone advise on where to begin? I was considering using tomekw/hikari-cp, but it doesn't have an adapter listed for Cockroach. Does this mean that I need to use brettwooldridge/HikariCP directly, without the Clj wrapper?

ag 2023-10-26T22:38:52.543269Z

Hmm... maybe I can just use postgres adapter settings?

seancorfield 2023-10-26T22:39:24.239929Z

HikariCP is pretty straightforward to use directly. Also, next.jdbc has pooling built-in, using HikariCP or c3p0.

ag 2023-10-26T22:43:31.979049Z

I know, I saw it. I'm planning to migrate to next.jdbc at some point. Right now, I have to tread very carefully; I just started on this project a few days ago. It's written using org.clojure/java.jdbc, so I need to try keeping changes to a minimum. For now.

seancorfield 2023-10-26T22:45:39.832189Z

Ah, sorry. Well, then look at what ->pool does and do that in your own code to create cpds and then {:datasource cpds} is your "db-spec" for c.j.j

seancorfield 2023-10-26T22:46:43.402139Z

Old Skool: https://clojure-doc.org/articles/ecosystem/java_jdbc/reusing_connections/ 🙂

👍 1
lukasz 2023-10-26T23:04:58.028839Z

Cockroach is (was?) wire-compatible with Postgres, so hikari-cp + PG driver should work, as per this doc: https://www.cockroachlabs.com/docs/stable/connection-pooling#example

👍 1