Fork me on GitHub
#sql
<
2020-03-17
>
grounded_sage14:03:08

With next.jdbc I’m trying to move some code from clojure.java.jdbc that uses a string URL like so. ":[email protected]:5432/DBNAME" . However this ends up different than using the spec hashmap when passed to (jdbc/get-datasource db-spec) . If I use the existing URL the queries fail. What am I doing wrong?

dpsutton14:03:41

using the information in that connection string can you create a db-spec with the required information?

grounded_sage14:03:26

This is datasource when I provide the details as the spec hash. #object[next.jdbc.connection$url_PLUS_etc$reify__6503 0x3e3886c2 "jdbc:"] This is when I provide the URL #object[next.jdbc.connection$url_PLUS_etc$reify__6503 0x16e837fc ":PASSWORD0.0.0.0:5432/DBNAME"]

dpsutton14:03:10

can you validate your db-spec? (clojure.spec.alpha/valid? :next.jdbc.specs/db-spec {:dbtype "postgres" :dbname "bob" :username "bob" :password "secretbob"})

dpsutton14:03:32

or turn on the instrumentation in next.jdbc.specs

dpsutton14:03:50

and read the doc of (doc jdbc/get-datasource)

grounded_sage14:03:22

Ok I will try. I can run queries with the db-spec hash just not the URL.

grounded_sage14:03:50

Both validate as true

seancorfield16:03:46

next.jdbc requires the jdbc: prefix.

seancorfield16:03:12

clojure.java.jdbc incorrectly let you omit it and it worked anyway (for some drivers?).

seancorfield16:03:26

The JDBC spec says all URLs must begin with jdbc:.

seancorfield16:03:49

About halfway down the page "Note that clojure.java.jdbc allowed the jdbc: prefix in a JDBC URI to be omitted but next.jdbc requires that prefix!"

seancorfield16:03:51

I will open an issue to update the spec to check the format of the URL anyway, so at least if folks instrument next.jdbc it would fail validation.