This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-03
Channels
- # announcements (2)
- # asami (1)
- # babashka (32)
- # beginners (125)
- # calva (4)
- # cider (1)
- # clj-kondo (16)
- # clj-together (1)
- # cljs-dev (15)
- # clojure (30)
- # clojure-australia (3)
- # clojure-europe (41)
- # clojure-italy (1)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (68)
- # clojure-uk (28)
- # clojurescript (36)
- # conjure (2)
- # cryogen (1)
- # cursive (2)
- # data-science (2)
- # datascript (2)
- # datomic (70)
- # events (2)
- # fulcro (11)
- # graalvm (1)
- # jobs (4)
- # kaocha (4)
- # leiningen (4)
- # malli (52)
- # meander (21)
- # off-topic (11)
- # pathom (7)
- # pedestal (17)
- # reagent (23)
- # reitit (5)
- # remote-jobs (5)
- # reveal (7)
- # shadow-cljs (24)
- # spacemacs (36)
- # sql (21)
- # vim (18)
- # xtdb (7)
I am using next.jdbc. I get the error Could not locate clojure/datafy__init.class or clojure/datafy.clj on classpath., compiling:(next/jdbc/result_set.clj:1:1)
when I import [next.jdbc.sql :as sql]]
could not find anyone facing this with a simple google search
next.jdbc requires clojure 1.10 i believe. in your deps.edn/project.clj file you can add a dependency on org.clojure/clojure "1.10.1"
or org.clojure/clojure {:mvn/version "1.10.1"}
depending on which deps manager you are using
oh okay..let me try that out
@U11BV7MTK thanks. yes, that seems to have solved the issue. Can I ask what made you suspect that it was the clojure version mismatch?
because clojure/datafy.clj
was introduced in clojure 1.10. as its in the core language and a recent addition, there aren't too many other possible culprits
datafy/nav were added to Clojure ~ 1.10, if you were using an earlier version they wouldn’t be found
got it:)
The second sentence of Getting Started is "It is designed to work with Clojure 1.10 or later" -- sounds like I need to make it clearer that is a requirement.
I updated the installation notes on the Getting Started page: https://github.com/seancorfield/next-jdbc/blob/develop/doc/getting-started.md#installation
Is there any real reason to use :read-only? true
(clojure.java.jdbc)?
More specifically for a single query and MySQL?
What about benefits for multiple queries?
I guess read javadoc for the MySQL jdbc driver? Notice it does not guarantee that you cannot write to the DB (I believe)
Indeed. It's much better, imho, to have a dedicated user for the db that has permissions only to select and connect using that.
@U06BE1L6T The JDBC API docs say that setting a connection to read only is "a hint to the driver to enable database optimizations" but the exact effect is going to be DB-specific I expect.
I've read some suggestions that you need to set the connection read only for some DBs to allow for streaming of large result sets, but that may also be confusion with the result set concurrency which I've also read suggestions that you need to select read only for result sets for that streaming to occur.
If you're just doing simple queries, I wouldn't expect it to make much difference but, as Jakub says, the only way to be more certain is to go digging in the MySQL documentation.
Thanks everyone. I wanted to check if this is something you commonly do. We have several such queries from a long time ago and nobody is sure why. Based on the MySQL docs, I'd say it doesn't bring anything (specifically for cases when there's just a single select): https://dev.mysql.com/doc/refman/5.6/en/innodb-performance-ro-txn.html • InnoDB can avoid the overhead associated with setting up the https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_transaction_id (TRX_ID field) for transactions that are known to be read-only. A transaction ID is only needed for a https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_transaction that might perform write operations or https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_locking_read such as SELECT ... FOR UPDATE. Eliminating unnecessary transaction IDs reduces the size of internal data structures that are consulted each time a query or data change statement constructs a https://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_read_view. • InnoDB detects read-only transactions when: • The transaction is started with the START TRANSACTION READ ONLY statement. • The autocommit setting is turned on, so that the transaction is guaranteed to be a single statement, and the single statement making up the transaction is a “non-locking” SELECT statement. That is, a SELECT that does not use a FOR UPDATE or LOCK IN SHARED MODE clause.
Yeah, and there's no JDBC API for directly starting a read only transaction, so using a read only connection in a context where JDBC itself would start a transaction is about the only way to do it, as far as I can tell from the JDBC docs. Auto-commit is turned on by default in JDBC and every operation is wrapped in a transaction by default. I'm still not clear on whether that's sufficient to trigger the InnoDB optimizations tho'...
Has an effect on Transaction locking or how data is fetched on replicated database servers?
@synthomat :read-only? true
affects connections (setting them to readonly). There is also a :read-only
value for result set concurrency, which is what you are thinking of, maybe?