jdbc中缺少必需的参数

时间:2022-02-18 22:50:09

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.

我一直在为clojures .java.jdbc的db-spec问题而抓狂。我想知道最近是否有一些行为发生了变化,因为直到最近才发生了类似的事情。

My db-spec looks like this:

我的db-spec看起来是这样的:

(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:

然后在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?

我也不知道NO_SOURCE_FILE是什么。我已经验证了oracle驱动程序是可访问的、已加载的等等。我在db-spec中可能遗漏了什么参数?

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

注意:我在MS SQL Server上有同样的问题。

1 个解决方案

#1


7  

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

问题是prod是一个函数,因此要么将prod更改为(def prod{这里的所有支柱}),要么在需要时调用prod函数:(with-connection (prod) (with-query-results)

#1


7  

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

问题是prod是一个函数,因此要么将prod更改为(def prod{这里的所有支柱}),要么在需要时调用prod函数:(with-connection (prod) (with-query-results)