This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-09
Channels
- # adventofcode (93)
- # announcements (11)
- # babashka (7)
- # babashka-sci-dev (17)
- # beginners (73)
- # biff (7)
- # calva (3)
- # cider (1)
- # clj-kondo (160)
- # clj-together (12)
- # clojure (44)
- # clojure-art (2)
- # clojure-europe (12)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-norway (22)
- # clojure-uk (2)
- # clojurescript (8)
- # clr (1)
- # cursive (6)
- # data-science (1)
- # datomic (1)
- # emacs (6)
- # events (1)
- # exercism (1)
- # fulcro (6)
- # graphql (2)
- # introduce-yourself (1)
- # lsp (18)
- # nrepl (7)
- # off-topic (45)
- # polylith (25)
- # portal (25)
- # practicalli (3)
- # re-frame (14)
- # reagent (28)
- # reitit (2)
- # releases (2)
- # shadow-cljs (73)
- # sql (11)
- # tools-deps (12)
- # transit (4)
- # xtdb (4)
next.jdbc
How do I read a blob? I get connection closed error when I try to do .getBinaryStream
. Do I have to do inside a transaction?
I'm not using pooling
you have to do it while the connection is open, doing inside a transaction just happens to do that
if you are just passing a map of connection parameters into plan or select or whatever, the connection is opened inside those and closed by the time they return
you can use https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.847/api/next.jdbc#get-connection to more explicitly manage the lifetime of a connection
@UC1DTFY1G https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.3.847/doc/getting-started/tips-tricks?q=blob#clob--blob-sql-types gives an example of getting the raw BLOB data as bytes rather than a stream which might help?
(the CLOB reading examples there use a stream but open and close it "atomically" to avoid the connection closed issue)
@U04V70XH6 I managed to get it working in the end. Got bitten by two things: 1. Connection closed error because I was using a connection param map
2. Trying to extend rs/ReadableColumn
to java.sql.Blob
failed and then I read the docs 😄
If you use .getBytes
you shouldn't have to. If you use .getBinaryStream
I would expect you'd need to use with-open
and read the entire BLOB inside that.