我正在尝试使用 Clojure/Lein 连接到 Oracle 数据库。
我从这里下载了 ojdbc.jar:http: //mirrors.ibiblio.org/maven/mule/dependencies/maven1/oracle-jdbc/jars/
然后我使用以下命令将它安装到我的本地存储库中:
mvn install:install-file -Dfile=C:\dev\tools\ojdbc14.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=9.2.0.5 -Dpackaging=jar -DgeneratePom=true
我的 project.clj 看起来像这样:
(defproject spike "0.1.0-SNAPSHOT"
:description "spike"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/java.jdbc "0.3.0-alpha4"]
[compojure "1.1.5"]
[ring/ring-json "0.1.2"]
[oracle/classes12dms "9.0.4"]
[com.oracle/ojdbc14 "9.2.0.5"]
]
:plugins [[lein-ring "0.8.5"] [lein-deps-tree "0.1.2"]]
:ring {:handler spike.handler/app}
:repositories [["internal" "http://xxx:8080/artifactory/repo"]
["jboss" "https://repository.jboss.org/nexus/content/groups/public"]
["jboss-dep" "https://repository.jboss.org/nexus/content/repositories/deprecated"] ]
)
访问的spikeDb.clj 看起来像这样:
(ns spike.spikeDb
(:require [clojure.java.jdbc :as jdbc]
[clojure.java.jdbc.sql :as sql])
(:import java.sql.Types))
(def devdb {:classname "oracle.jdbc.driver.OracleDriver"
:subprotocol "oracle"
:subname "thin:xxx/xxx@xxx:1528/xxx"})
(defn get-xxx [id]
(jdbc/query devdb
(sql/select [:TITLE :DESCRIPTION]
:XXX (sql/where {:CODE id}))))
我使用加载服务器
lein ring server
但是当我导航到该页面时,我得到了这个:
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:xxx/xxx@xxx:1528/xxx
DriverManager.java:604 java.sql.DriverManager.getConnection
DriverManager.java:190 java.sql.DriverManager.getConnection
jdbc.clj:206 clojure.java.jdbc/get-connection
jdbc.clj:628 clojure.java.jdbc/db-with-query-results*
jdbc.clj:646 clojure.java.jdbc/query
RestFn.java:425 clojure.lang.RestFn.invoke
spikeDb.clj:13 spike.spikeDb/get-xxx
我究竟做错了什么??!