Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing required parameter in clojure.java.jdbc

I've been tearing my hair out over an issue with db-specs in clojure.java.jdbc. I'm wondering if some behavior has changed recently, because something almost identical to this worked up until very recently.

My db-spec looks like this:

(defn prod []
  "Yes, I've verified all of the loaded properties are accurate for the connection"
  { :classname (get-property "acedia.bbts")
  :subprotocol (get-property "acedia.bbts.subprotocol")
  :subname (str "@" (get-property "acedia.bbts.dev.host") ":" (get-property "acedia.bbts.dev.port") ":" (get-property "acedia.bbts.dev.sid"))
  :user (get-property "acedia.bbts.dev.user")
  :password (get-property "acedia.bbts.dev.password")})

And then at the REPL:

user => (prod)
{:classname "oracle.jdbc.driver.OracleDriver", :subprotocol "oracle", :subname "@hostname:1521:bbts", :user "user", :password "pass"}

user=> (with-connection bbts-dev (with-query-results rs ["select * from customer where rownum < 10"] (dorun (map #(println (:firstname %)) rs))))

user => (use 'clojure.stacktrace)
nil
user => (e)
java.lang.IllegalArgumentException: db-spec acedia.db.bbts$prod@4d24bd93 is missing a required parameter
at clojure.java.jdbc.internal$get_connection.invoke (internal.clj:147)
  clojure.java.jdbc.internal$with_connection_STAR_.invoke (internal.clj:154)
  user$eval1116.invoke (NO_SOURCE_FILE:1)
  clojure.lang.Compiler.eval (Compiler.java:6465)
  clojure.lang.Compiler.eval (Compiler.java:6431)
  clojure.core$eval.invoke (core.clj:2795)
  clojure.main$repl$read_eval_print__5967.invoke (main.clj:244)
  clojure.main$repl$fn__5972.invoke (main.clj:265)
nil

I have no idea what the NO_SOURCE_FILE is in reference to, either. I've verified that the oracle driver is accessible, loaded, etc., as well. What parameter could I be missing in the db-spec?

Note: I have the same problem with MS SQL Server.

like image 559
Jason Lewis Avatar asked Sep 05 '12 18:09

Jason Lewis


1 Answers

The issue is that prod is a function, so either change prod to be (def prod {all props here}) or call the prod function when needed: (with-connection (prod) (with-query-results

like image 184
DanLebrero Avatar answered Nov 03 '22 03:11

DanLebrero