“oracle”函数在Korma中的确切用法以及clojure代码的含义?
我正在尝试使用Korma连接到Oracle数据库。首先,我尝试使用此代码并成功连接“oracle”函数在Korma中的确切用法以及clojure代码的含义?,clojure,korma,sqlkorma,Clojure,Korma,Sqlkorma,我正在尝试使用Korma连接到Oracle数据库。首先,我尝试使用此代码并成功连接 (defdb korma-db {:classname "oracle.jdbc.OracleDriver" :subprotocol "oracle" :subname "thin:@my.oracle.db:1521:testdb" :user "xxx" :password "xxx" :naming {:keys str/lower-case :fields str/up
(defdb korma-db
{:classname "oracle.jdbc.OracleDriver"
:subprotocol "oracle"
:subname "thin:@my.oracle.db:1521:testdb"
:user "xxx"
:password "xxx"
:naming {:keys str/lower-case :fields str/upper-case}})
但是我发现有一个更方便的函数korma.db.oracle
。因此,代码可以简化为:
(defdb korma-db
(oracle {:keys ["my.oracle.db" 1521 true]
:as {:user "xxx" :password "xxx"}
:naming {:keys str/lower-case :fields str/upper-case}}))
(defdb korma-db
(oracle {:subname "@//xxx.xxx.xxx.xxx:1521/testdb"
:user "xxx"
:password "xxx"
:naming {:keys str/lower-case :fields str/upper-case}}))
但它失败了。它试图localhost
。当我检查oracle
函数的结果时,我发现有些奇怪
{:naming {:keys #<string$lower_case clojure.string$lower_case@5ba760ac>,
:fields #<string$upper_case clojure.string$upper_case@504f4c0b>},
:as {:user "xxx", :password "xxx"},
:keys ["my.oracle.db" 1521 true],
:classname "oracle.jdbc.driver.OracleDriver",
:subprotocol "oracle:thin",
:subname "@localhost:1521", :make-pool? true}
^^^^^^^^^
简言之,我的问题是:
函数的确切用法是什么?我错过了什么oracle
- 对我来说,
函数的代码看起来很奇怪。有人能解释一下吗 请输入代码,尤其是参数部分…oracle
[{:keys[主机]:或{…}:as…}]
功能。这是一个例子
因此,调用oracle的正确方法是:
(defdb korma-db
(oracle { :user "xxx"
:password "xxx"
:host "my.oracle.db"
:port 1521
:make-pool? true }))
编辑:
可以按如下方式指定oracle SID:
(defdb korma-db
(oracle {:keys ["my.oracle.db" 1521 true]
:as {:user "xxx" :password "xxx"}
:naming {:keys str/lower-case :fields str/upper-case}}))
(defdb korma-db
(oracle {:subname "@//xxx.xxx.xxx.xxx:1521/testdb"
:user "xxx"
:password "xxx"
:naming {:keys str/lower-case :fields str/upper-case}}))
非常感谢。我还发现stackoverflow中有一个问答。如何指定oracle SID?不知道,我自己从未使用过korma我现在能理解代码了。不幸的是,我现在无法测试连接。无论如何,谢谢。虽然我无法用上面的代码连接到oracle数据库,但我知道了重要的事情,映射绑定表单。我找到了一个如何使用oracle
功能的页面: