Fork me on GitHub
#sql
<
2021-03-18
>
zackteo13:03:58

May I ask how do I specify the driver for postgresql? No suitable driver found for jdbc: Am trying

(def db {:dbtype "postgresql" :port "25432" :dbname "gis"})

(def ds (jdbc/get-datasource db))

(jdbc/execute! ds ["select * from hex200 limit 1"])

Darin Douglass13:03:05

you just have to add the right dependency to your deps:

[org.postgresql/postgresql "some version"]

zackteo13:03:46

this is in both my project.clj and my require in the file right?

Darin Douglass13:03:00

you don't have you require it, no. it just has to be on your classpath

Darin Douglass13:03:19

and yep, if you're using lein plop that into your :dependencies

zackteo13:03:34

okay will try! May I ask if there is a list of dependencies to their databases?

Darin Douglass13:03:03

not that i'm aware of, though we only use postgres ¯\(ツ)

Darin Douglass13:03:27

most databases should have java driver lists somewhere in their documentation

zackteo13:03:41

I see I see!

zackteo13:03:18

Just wanted to know if i do ever use a different database - but am likely just using postgresql for postgis and pgrouting

zackteo13:03:43

Thanks! i got it working!

zackteo13:03:12

Am following the getting-started but and understand there is com.h2database/h2 {:mvn/version "1.4.199"} . May I ask what is/where do i find the equivalent for postgresql and where do i put it

seancorfield16:03:15

@zackteo The Getting Started guide for next.jdbc has a link to https://github.com/seancorfield/next-jdbc/blob/develop/deps.edn#L10-L27 which is a list of DB drivers that next.jdbc has been tested against. That’s on this page https://cljdoc.org/d/seancorfield/next.jdbc/1.1.646/doc/getting-started in the paragraph that says “In addition, you will need to add dependencies for the JDBC drivers you wish to use for whatever databases you are using. You can see the drivers and versions that next.jdbc is tested against in the project’s deps.edn file, but many other JDBC drivers for other databases should also work (e.g., Oracle, Red Shift).” The italicized phrase is the link to the list of drivers.

seancorfield16:03:46

I always welcome suggestions on improving the docs to make stuff like this easier/more obvious…

zackteo21:03:41

I did read through that part and even went to the deps.edn but it somehow wasn't immediately obvious then. When re-reading the documentation, however, it is very clear :thinking_face: Maybe I just got distracted midway hmmmm, I was thinking the deps.edn would be dependencies for next.jdbc, which in hindsight makes perfect sense, since you need those dependencies to run tests

zackteo21:03:52

I wonder if an example like "In addition, you will need to add dependencies for the JDBC drivers you wish to use for whatever databases you are using. For example org.postgresql/postgresql for postgresql." would be good

seancorfield21:03:02

’k… if you think there’s a clearer way to show it in the docs, I’m happy to update things. Perhaps even just listing a few popular databases and their drivers? Although versions change often…

seancorfield21:03:09

Hah, yeah, we’re on the same page!

seancorfield21:03:26

Sure, I can make that update…

zackteo21:03:51

I could do a quick pull request if that's better for you

zackteo21:03:05

was wondering if "You can see the drivers and versions" -> "You can see the list of drivers and versions" might make a difference. In my brain, I was looking for a list of drivers

zackteo21:03:22

maybe I was confused about the dependencies part because I saw org.postgresql.Driver too - but that's probably just me veering off the getting started documentation

zackteo21:03:25

Looks good!