This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-05
Channels
- # announcements (19)
- # babashka (28)
- # beginners (62)
- # biff (3)
- # calva (19)
- # cider (24)
- # clj-kondo (8)
- # cljdoc (15)
- # clojure (32)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-uk (8)
- # clojuredesign-podcast (26)
- # cursive (64)
- # datomic (43)
- # deps-new (1)
- # fulcro (4)
- # honeysql (1)
- # hyperfiddle (46)
- # kaocha (16)
- # lsp (15)
- # missionary (51)
- # music (1)
- # nbb (4)
- # off-topic (55)
- # pedestal (11)
- # podcasts-discuss (1)
- # polylith (7)
- # practicalli (1)
- # releases (4)
- # shadow-cljs (120)
- # tools-build (34)
- # vscode (1)
- # xtdb (2)
I’ve downloaded and am trying to run datomic-pro-1.0.6735
.
I’m trying to run a transactor against MS SQL Server (in a Docker container).
I’ve also included maven/com.microsoft.sqlserver/[email protected]
in Datomic Pro’s pom.xml
.
But when I try to run it using sqlserver-transactor.properties
, I get a ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
.
👉:skin-tone-5: How do I make the SQL Server driver available to the Transactor and Peer?
./bin/transactor config/sqlserver-transactor.properties
Terminating process - Lifecycle thread failed
java.util.concurrent.ExecutionException: java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
...
Caused by: java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:253)
...
Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
...
Files
# config/sqlserver-transactor.properties
protocol=sql
host=localhost
port=1433
sql-url=jdbc:;database=datomic;encrypt=true;trustServerCertificate=true;
sql-user=...
sql-password=...
sql-driver-class=com.microsoft.sqlserver.jdbc.SQLServerDriver
sql-validation-query=select 1
# pom.xml
<dependencies>
...
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>12.4.1.jre11</version>
</dependency>
> Only the Postgres driver is included with the transactor distribution. For other SQL distributions, you will have to make the driver available on the classpath of the transactor (by placing it in <datomic-install>/lib).
You can also set DATOMIC_EXT_CLASSPATH
instead of copying stuff into lib if you want https://docs.datomic.com/pro/reference/database-functions.html#classpath-functions
Is it possible to use collection binding in a way that ensures all elements within it are combined using the AND operator? For instance, in the given example query:
(d/q '[:find ?e
:in $ [[?attr ?val] ...]
:where [?e ?attr ?val]]
db [[:attr/name "value1"]
[:attr/name2 "value2"]])
I want to query entities where both conditions are simultaneously satisfied.(let [db :DB
conditions [[:attr/name "value1"]
[:attr/name2 "value2"]]
args (into [db]
cat
conditions)
in (into ['$]
(mapcat (fn [i] [(symbol nil (str "?attr" i))
(symbol nil (str "?val" i))]))
(range (count conditions)))
where (into []
(map (fn [i] ['?e
(symbol nil (str "?attr" i))
(symbol nil (str "?val" i))]))
(range (count conditions)))
query-map {:query {:find '[?e]
:in in
:where where}
:args args}]
query-map)
{:query {:find [?e], :in [$ ?attr0 ?val0 ?attr1 ?val1], :where [[?e ?attr0 ?val0] [?e ?attr1 ?val1]]},
:args [:DB :attr/name "value1" :attr/name2 "value2"]}
I have used rules, but your solution is probably better for caching?
(defn find-entity
[db & args]
(let [attrs (if (= 1 (count args))
[[:db/id (first args)]]
(partition 2 args))
rules [(into ['(applied ?e)]
(map (fn [[attr val]]
['?e attr val])
attrs))]]
(when-let [e (d/q '[:find ?e .
:in $ %
:where (applied ?e)]
db rules)]
(d/touch (d/entity db e)))))
I’m not sure there’s any significant difference between building a rule with inlined values and building a query with inlined values.
if you want max query plan caching (and know the overhead is significant), what I did is best because it can share the plan per count of args
One other things re. https://clojurians.slack.com/archives/C03RZMDSH/p1696519994616739?thread_ts=1696519320.426689&cid=C03RZMDSH.
And beyond that, I’m failing with :db.error/read-transactor-location-failed Could not read transactor location from storage
when trying to d/create-database
.
./bin/repl
user=> (require '[datomic.api :as d])
user=> (def db-uri "datomic:...")
user=> (d/create-database db-uri)
Execution error (Exceptions$IllegalArgumentExceptionInfo) at datomic.error/arg (error.clj:79).
:db.error/read-transactor-location-failed Could not read transactor location from storage
👉:skin-tone-5: Why can’t the Peer d/create-database
, if the “db.sql” “table.sql” and “user.sql” have been setup ok? SQL Server and the Transactor are https://clojurians-log.clojureverse.org/datomic/2020-04-22. All the preambles seem ok.
• ok. docker run ... -d
• ok. Checked SQL Server connection in Datagrip
• ok. Datomic DB creation scripts (for sqlserver) are good: “db.sql” “table.sql” and “user.sql” (analog to https://docs.datomic.com/pro/overview/storage.html#sql-database)
• ok. Succeeded with ./bin/transactor config/sqlserver-transactor.properties
Yes! Although without much information.
./bin/transactor config/sqlserver-transactor.properties
Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
System started
It should… config/sqlserver-transactor.properties
protocol=sql
host=localhost
port=4334
sql-url=jdbc:;database=datomic;encrypt=true;trustServerCertificate=true;
sql-user=datomic
sql-password=...
sql-driver-class=com.microsoft.sqlserver.jdbc.SQLServerDriver
sql-validation-query=select 1
memory-index-threshold=32m
memory-index-max=256m
object-cache-max=128m
SQL
-- db.sql
USE master;
GO
CREATE DATABASE datomic COLLATE Latin1_General_100_CI_AS_SC_UTF8;
GO
-- table.sql
USE datomic;
GO
CREATE TABLE datomic_kvs
(
id varchar(900) NOT NULL,
rev int,
map nvarchar(max),
val varbinary(max),
CONSTRAINT pk_id PRIMARY KEY (id)
);
GO
GRANT ALL ON datomic_kvs TO public;
GO
-- MSSQL-user.sql
CREATE LOGIN datomic WITH PASSWORD = '...';
GO
USE datomic;
GO
CREATE USER datomic FOR LOGIN datomic;
GO
“do you see rows in the table?” Now that you mention it… In Datagrip, no I don’t see the table I created
“also check for errors in your $DATOMIC/logs dir” Ermm, just a bunch of Transactor heartbeats in there.
Apologies if this has already been brought up: I don't see any mention of :query-stats
here https://docs.datomic.com/pro/clojure/index.html