sql

All things SQL and JDBC...
zackteo 2021-03-18T13:47:58.013300Z

May I ask how do I specify the driver for postgresql? No suitable driver found for jdbc:<postgresql://127.0.0.1:25432/gis> 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 Douglass 2021-03-18T13:49:05.014400Z

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

[org.postgresql/postgresql "some version"]

zackteo 2021-03-18T13:49:12.014700Z

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

zackteo 2021-03-18T13:49:46.014800Z

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

Darin Douglass 2021-03-18T13:50:00.015Z

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

Darin Douglass 2021-03-18T13:50:19.015200Z

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

Darin Douglass 2021-03-18T13:50:53.015400Z

you can find versions here: https://search.maven.org/artifact/org.postgresql/postgresql]

zackteo 2021-03-18T13:51:34.015800Z

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

Darin Douglass 2021-03-18T13:52:03.016Z

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

Darin Douglass 2021-03-18T13:52:27.016200Z

most databases should have java driver lists somewhere in their documentation

zackteo 2021-03-18T13:52:41.016400Z

I see I see!

zackteo 2021-03-18T13:53:18.016600Z

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

zackteo 2021-03-18T13:54:43.016800Z

Thanks! i got it working!

Darin Douglass 2021-03-18T14:01:55.017Z

:catjam:

seancorfield 2021-03-18T16:27:15.018900Z

@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.

seancorfield 2021-03-18T16:27:46.019700Z

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

zackteo 2021-03-18T21:03:41.024500Z

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

zackteo 2021-03-18T21:05:52.026700Z

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

seancorfield 2021-03-18T21:06:02.026900Z

’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…

seancorfield 2021-03-18T21:06:09.027100Z

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

seancorfield 2021-03-18T21:06:26.027500Z

Sure, I can make that update…

zackteo 2021-03-18T21:06:51.028Z

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

zackteo 2021-03-18T21:10:05.029500Z

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

zackteo 2021-03-18T21:16:22.031100Z

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

zackteo 2021-03-18T21:17:25.031700Z

Looks good!