sql

All things SQL and JDBC...
onetom 2020-03-20T06:54:39.248600Z

is there a way to specify a timeout for next.jdbc/get-connection?

onetom 2020-03-20T07:01:48.250500Z

actually, i might be experiencing some other kind of timeout, since im accessing my db server over a ssh socks proxy which is tunnelled to my machine also over ssh this is my proxy handling code, if anyone is curious:

(defn proxy-props [& [props]]
  (->> (or props (System/getProperties))
       (filter #(str/includes? (key %) "Proxy"))
       (into {})))

(defn activate-socks-proxy! [host port]
  (proxy-props
    (doto ^Properties (System/getProperties)
      (.setProperty "socksProxyHost" host)
      (.setProperty "socksProxyPort" (str port)))))

(defn deactivate-socks-proxy! []
  (proxy-props
    (doto ^Properties (System/getProperties)
      (.remove "socksProxyHost")
      (.remove "socksProxyPort"))))


(comment
  (proxy-props)
  (activate-socks-proxy! "localhost" 1081)
  (deactivate-socks-proxy!)
  )

seancorfield 2020-03-20T15:02:19.251500Z

You should be able to specify :loginTimeout in the db spec used to create the datasource (that you then get the connection from) @onetom

seancorfield 2020-03-20T15:03:25.252900Z

On a statement level, you can specify :timeout in the options (anywhere a prepared statement would be created and executed) -- that one is in the documentation (see *All the Options* and elsewhere).

seancorfield 2020-03-20T15:04:17.254Z

The former -- :loginTimeout -- is not specifically documented, but I believe the docs explain that arbitrary options can be passed through to the get connection process from the db spec hash map?

onetom 2020-03-20T15:34:29.254100Z

Yes, the arbitrary option passing is explained, I just didn't have the intuition what to google for, since I'm not familiar with the JDBC ecosystem...

onetom 2020-03-20T15:35:00.254300Z

Yes, I found that and it was clearly explained; no issue there

onetom 2020-03-20T15:35:43.254500Z

Thanks! So I guess I have to read the various JDBC adapter's documentation to figure out what kind of options do they support.