1

New to clojure. Trying to connect to the oracle database and getting an error

SQLException ORA-28040: No matching authentication protocol
  oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112)

I am suspecting something wrong with the dependencies but I am too new to figure out

Here is my project.clj file

(defproject my_project "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/java.jdbc "0.6.1"]       
                 [com.oracle.jdbc/com.springsource.oracle.jdbc "10.2.0.2"]
                 [com.oracle.xdb/com.springsource.oracle.xdb "10.2.0.2"]])

And here is the code. I am trying to execute the f2 function in REPL and that is when I get the error

;; defines the parameters for connecting to the database
(def db-info {:hostname "dont.want.to.tell.com"
              :port 1521
              :database "db"
              :user "someuser"
              :password "somepassword"})

;; creates connection string from the db-info map
(defn get-connection-string [db-info] 
  (str "thin:@" (:hostname db-info) ":" (:port db-info) ":" (:database db-info))) 


;;defines the db map that would be used for queries
 (def db {:classname "oracle.jdbc.OracleDriver"  
           :subprotocol "oracle"
           :subname (get-connection-string db-info) 
           :user (:user db-info)
           :password (:password db-info)})

 (defn f2 [] 
  (jdbc/query db ["select * from secret_table where rownum < 2"] {:row-fn :cost})) 
SK176H
  • 1,319
  • 3
  • 14
  • 25
  • What Oracle driver version are you using? Take a look at similar issues on SO, e.g. http://stackoverflow.com/a/26604277/597473 – Piotrek Bzdyl Jun 02 '16 at 19:13

1 Answers1

1

This errors happens when Oracle is configured to restrict client version access through the SQLNET.ORA parameter SQLNET.ALLOWED_LOGON_VERSION_CLIENT. This restriction is usually enforced to to avoid insecure cryptographic functions used by earlier versions of the Oracle client.

Changing the dependencies solved the issue :

(defproject my_project "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/java.jdbc "0.6.1"]       
                  [com.oracle/ojdbc6 "11.2.0.4"]                 
                 ])
Jon Heller
  • 34,999
  • 6
  • 74
  • 132
SK176H
  • 1,319
  • 3
  • 14
  • 25