The problem is that your way to connect to the database will not always be, although JNDI; for example, when testing or in REPL, you can manage your own connection pool.
I suggest you keep the db specification as var . Thus, the only change to your code is to rename the variable; because you intend to reinstall it, usually use asterisks:
(def *db-spec* {:name "jndi name"}) (defn query [q] (sql/with-connection *db-spec* (sql/with-query-results rs q (time (vec rs))))) (query "select * from Students")
And when testing on repl, just create your own data source, say Commons-DBCP, and reinstall its db specification.
(def ds (doto (BasicDataSource.) (.setDriverClassName "oracle.jdbc.OracleDriver") (.setUsername "tiger") (.setPassword "scott"))) (binding [*db-spec* {:datasource ds}] (query "select * from Students"))
source share