The :timeout
option causes .setQueryTimeout
to be called on the PreparedStatement
used under the hood of clojure.java.jdbc
. It is in seconds, not milliseconds, so your query would have to be extremely slow for a timeout of 2,000 seconds (just over half an hour) to take effect.
JDBC supports several different timeouts across several of its classes. For example, javax.sql.DataSource
supports .setLoginTimeout
(also in seconds), as does java.sql.DriverManager
.
There are also database-specific options you can add to the connection string (which you can add as additional key/value pairs in your "db-spec") to control lower-level timeouts. For example, MySQL supports connectionTimeout
and socketTimeout
in the connection string -- and both of those are in milliseconds. clojure.java.jdbc
allows for those to be provided in your "db-spec" hash map as :connectTimeout
and :socketTimeout
keys respectively.
Note that clojure.java.jdbc
is considered "Stable" at this point and all current and future development effort is focused on next.jdbc
at this point. next.jdbc
makes it easier to use the loginTimeout
since it operates on JDBC objects directly, so the whole (Java) API is available as well. It also has built-in support for connection pooling and is, overall, simpler and faster than clojure.java.jdbc
.