This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-07
Channels
- # announcements (1)
- # babashka (31)
- # beginners (54)
- # biff (3)
- # calva (22)
- # cider (13)
- # circleci (1)
- # clj-kondo (6)
- # cljsrn (2)
- # clojure (113)
- # clojure-europe (58)
- # clojure-mexico (5)
- # clojure-nl (3)
- # clojure-uk (7)
- # clojurescript (81)
- # cursive (20)
- # datomic (33)
- # events (3)
- # fulcro (29)
- # introduce-yourself (1)
- # meander (78)
- # off-topic (60)
- # om-next (2)
- # podcasts-discuss (1)
- # re-frame (8)
- # reagent (5)
- # reitit (20)
- # remote-jobs (1)
- # shadow-cljs (24)
- # spacemacs (10)
- # sql (8)
- # tools-deps (22)
- # xtdb (16)
Got it! Thanks for the help and explanation.
Hi, I’m on a project using java.jbc (not next) with Postgres, and I’m trying to get the database to return JSR-310 LocalDate/Times. Currently I’m getting back java.sql.Timestamp
Apparently the https://jdbc.postgresql.org/documentation/head/8-date-time.html, but i’m unsure what step i’m missing to get it to return JSR-310 things.
I’m using:
org.clojure/java.jdbc {:mvn/version "0.7.12"}
org.postgresql/postgresql {:mvn/version "42.2.20"}
Is there some other configuration needed?(extend-protocol clojure.java.jdbc/IResultSetReadColumn
java.sql.Timestamp
(result-set-read-column [^Timestamp ts _ _]
(->local-date ts)))
Where ->local-date
will be your function to convert java.sql.Timestamp to LocalDate.You can just include this namespace: https://github.com/seancorfield/next-jdbc/blob/develop/src/next/jdbc/date_time.clj
@U06790Y4E I'd recommend switching to next.jdbc
if you can, since this is supported directly. If you need to keep using c.j.j, you'll have to extend the (similar but different) protocols per indy
's suggestion.
@U04V70XH6 ok, thanks for the tip. Moving to next.jdbc is on the agenda, i’m trying to transition us there now and switching the dates to be java.time is one of the steps. I’ll extend the protocols for now. I originally thought i wouldn’t have to do that based off the Postgres docs, but I don’t fully understand each layer at the mo
You can do it at the raw JDBC layer if you tell the driver what type the column is -- but c.j.j and next.jdbc
don't know that information (in any portable, useful way) so they just traffic in Object
s. Some drivers accept Java Time types and will coerce them to SQL types -- but PG won't even do that for java.util.Date
without some assistance, which is where the next.jdbc.date-time
namespace comes in: it adds automatic support for setting parameters based on both Java Time types and java.util.Date
, and three functions that add support for reading SQL date/time types as different Java Time types.