1

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?

1
  • just including the libraries in your dependency doesn't configure your connection to the database. you have to specify that specifically, typically in the :classname value of the connection map. Commented Mar 1, 2016 at 10:58

2 Answers 2

2

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})
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.