This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-30
Channels
- # announcements (15)
- # beginners (143)
- # boot (2)
- # calva (48)
- # cider (93)
- # cljsrn (2)
- # clojure (127)
- # clojure-europe (3)
- # clojure-italy (8)
- # clojure-losangeles (8)
- # clojure-nl (10)
- # clojure-spec (67)
- # clojure-uk (51)
- # clojurescript (20)
- # cursive (9)
- # data-science (2)
- # datomic (10)
- # duct (13)
- # figwheel-main (1)
- # fulcro (74)
- # instaparse (10)
- # jobs (3)
- # joker (8)
- # juxt (4)
- # lumo (1)
- # malli (11)
- # nrepl (3)
- # off-topic (4)
- # pathom (5)
- # pedestal (6)
- # planck (5)
- # re-frame (18)
- # reagent (5)
- # reitit (17)
- # shadow-cljs (165)
- # sql (30)
- # vim (12)
- # xtdb (6)
hello all, I have a monitoring processa that read results from sqlserver database. Sometimes the result query does not came up and the cicle pool does not repeat, even I configure timeout for it. Is there any way to have outside timeout?
@fabrao I'm not sure I understand what you're asking... Are you saying the query just "hangs" indefinitely? How are you configuring the timeout?
Yes -> "Are you saying the query just "hangs" indefinitely?"
{:timeout 100 :dbtype "mssql"}
What makes you think that sets a timeout?
Release 0.3.6 on 2014-10-28
Arbitrary values allowed for :cursors, :concurrency, :result-type arguments to prepare-statement JDBC-102.
Allow :as-arrays? :cols-as-is to omit column name uniqueness when returning result sets as arrrays JDBC-101.
Add :timeout argument to prepare-statement JDBC-100.
That's an ancient version of clojure.java.jdbc
.
I'm looking at the code now to see what it actually does.
Hmm, OK, that should call .setQueryTimeout
on the statement when you (or c.j.j.) calls prepare-statement
...
I don't believe that option in a db-spec
is propagated to prepare-statement
from query
but I'd have to do some debugging to be certain.
oh, sorry about using it in wrong way, I have to replace or complement it in many funcs
I think if you put :queryTimeout 100
in the db-spec instead of just :timeout
it will work.
I´m thinking using this
(defn wait [ms f & args]
(let [c (chan)]
(go (>! c (apply f args)))
(first (alts!! [c (timeout ms)]))))
for query timeout, is that ok?:queryTimeout
and :cancelTimeout
(and a bunch of other timeouts) are supported at the DriverManager
level for MS SQL's standard JDBC driver.
Not sure how you think that core.async
code is going to affect anything about a JDBC query?
Actually, now I look at the code in more detail, it does look like :timeout
in the db-spec should be merged with the options passed to query
and then into prepare-statement
... But maybe .setQueryTimeout
on the (prepared) statement is not sufficient for whatever use case you have with your query...?
Yes, I figured. That's not what I meant.
There are all sorts of timeouts that can be set when a connection is created against the MS SQL driver https://docs.microsoft.com/en-us/sql/connect/jdbc/setting-the-connection-properties?view=sql-server-ver15
I don't think you are understanding me correctly 😐
Share more of your code. I need to see what arguments you're passing to query
and how/whether you are getting a connection or transaction first, or relying on query
to do that.
I´m just using (jdbc/query db-spec [query])
with db-spec as
{:host "10.10.20.70"
:port 1433 :timeout 100
:dbname "monitoramento"
:user "admin"
:password #senha "************"}
OK, that will pass timeout
as a property to DriverManager/getConnection
which will do nothing, but it should also pass timeout
into the prepare-statement
call behind the scenes which should call .setQueryTimeout
on the PreparedStatement
object which I would hope MS SQL's JDBC driver supports.
But I would definitely try :queryTimeout
and maybe :cancelTimeout
in the db-spec hash map and see if that works better.