Always Stuck
Always Stuck

Reputation: 13

Clojure Postgresql Drivers not found

I'm at that point where frustration just makes you incapable of seeing the solution...

My project.clj

:dependencies [[org.clojure/clojure "1.8.0"]                                                                                                                                                           
               [org.clojure/java.jdbc "0.4.2"]                                                                                                                                                         
               [org.postgresql/postgresql "9.4.1208"]] 
  1. Run lein deps (all is okay)
  2. Run my query:

    (db/query "postgresql://user:secret@host"
    ["select * from table limit 1"])

I get the following error:

  1. Unhandled java.sql.SQLException No suitable driver found for
    jdbc:postgresql://host

...Please. Any ideas?

Upvotes: 1

Views: 241

Answers (2)

number23_cn
number23_cn

Reputation: 4629

maybe your db spec is wrong, I use postgresql spec:

postgres://user:password@host:5432/mydb

Upvotes: 0

Nicolas Modrzyk
Nicolas Modrzyk

Reputation: 14197

Probably need to specify the java driver to use and the other parameters in the db descriptor.

I usually use something similar to:

(use 'clojure.java.jdbc)

(let [db { :classname "org.postgresql.Driver"
           :subprotocol "postgresql"
           :subname "//192.168.99.100:5432/postgres"
           :user "postgres"
           :password "mysecretpassword"}]
       (query db ["select count(*) from example" ]) )

 ; ({:count 6005247})

Upvotes: 2

Related Questions