0

I'm trying to follow this tutuorial https://devcenter.heroku.com/articles/clojure-web-application . I'm running into some difficulties with the very initial steps though, of setting up a local postgresql database for testing.

The first snag was that running "postgres -D pg" in the windows shell resulted in an error of "Execution of PostgreSQL by a user with administrative permissions is not permitted". To get a round that, I tried running pg_ctl start -D .\ .I think it worked, except that it couldn't access the "postgresql.conf" file.

Running "creatdb shouter" didn't work either, so I ran "createdb -U postgres shouter". But now when I try to launch lein repl, I just get this error:

$lein repl
Could not find artifact postgresql:postgresql:pom:8.4-702.qdbc4 in central (http://repo1.maven.org/maven2
Could not find artifact postgresql:postgresql:pom:8.4-702.qdbc4 in clojars (https://clojars.org/repo/)
Could not find artifact postgresql:postgresql:jar:8.4-702.qdbc4 in central (http://repo1.maven.org/maven2
Could not find artifact postgresql:postgresql:jar:8.4-702.qdbc4 in clojars (https://clojars.org/repo/)
Check :dependencies and :repositories for typos.
It's possible the specified jar is not in any repository.
If so, see "Free-floating Jars" under http://j.mp/repeatability
Exception in thread "Thread-1" clojure.lang.ExceptionInfo: Could not resolve dependencies {:exit-code 1}
        at clojure.core$ex_info.invoke(core.clj:4227)
        at leiningen.core.classpath$get_dependencies.doInvoke(classpath.clj:128)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.core$apply.invoke(core.clj:605)
        at leiningen.core.classpath$resolve_dependencies.doInvoke(classpath.clj:144)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at leiningen.core.eval$prep.invoke(eval.clj:60)
        at leiningen.core.eval$eval_in_project.invoke(eval.clj:220)
        at leiningen.repl$start_server.doInvoke(repl.clj:65)
        at clojure.lang.RestFn.invoke(RestFn.java:470)
        at leiningen.repl$repl$fn__1788.invoke(repl.clj:145)
        at clojure.lang.AFn.applyToHelper(AFn.java:159)
        at clojure.lang.AFn.applyTo(AFn.java:151)
        at clojure.core$apply.invoke(core.clj:601)
        at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1771)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at clojure.core$apply.invoke(core.clj:605)
        at clojure.core$bound_fn_STAR_$fn__3984.doInvoke(core.clj:1793)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Unknown Source)
2
  • You should really consider doing this on linux instead of windows. Commented Dec 28, 2012 at 23:49
  • Windows is fine, and at least in my opinion should be a first class development environment for Clojure (and we should strive to make it so) if you wan't to run the PostgreSQL instance on a linux box and stay within your comfortable Windows environment then addind a "local port forwad" to port 5432 on a linux box using PuTTY can make this more convenient. Commented Dec 29, 2012 at 3:40

1 Answer 1

1

That looks like your project.clj file may not have the correct dependencies specified. here is short example project with working dependencies to compare with:

project.clj:

(defproject hello "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/java.jdbc "0.2.3"]
                 [postgresql/postgresql "8.4-702.jdbc4"]])

which works from the repl.

user> (require '[clojure.java.jdbc :as sql])
nil

user> (def pgsqldb {:subprotocol "postgresql"                                                              
                    :subname "//127.0.0.1:5432/dbname"                                                    
                    :user "postgres"                                                                       
                    :password "...."})
#'user/pgsqldb
user> (sql/with-connection pgsqldb )
nil

user> (sql/with-connection pgsqldb 
         (sql/with-query-results rs ["SELECT * 
                                      FROM information_schema.tables 
                                      WHERE table_type = 'BASE TABLE' 
                                        AND table_schema = 'public' 
                                      ORDER BY table_type, table_name"] 
           (count rs)))
50
Sign up to request clarification or add additional context in comments.

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.