Search code examples
postgresqlclojurewindows-7gitlabring

after lein ring server, I get error PSQLException no password was provided


I am naive in Postgres and clojure

I wanted to run this https://gitlab.com/dzaporozhets/clojure-picture-gallery

Install

git clone https://gitlab.com/clojure-code-examples/picture-gallery.git
cd picture-gallery

# Install dependencies
lein deps

# Create database
psql -c 'CREATE DATABASE gallery TEMPLATE template0'

Running

To start a web server for the application, run:

lein ring server

this is process I have to do. 1)) I had to git clone but git clone have not worked. they want to let me type id, password. like this:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\jiji>git clone https://gitlab.com/clojure-code-examples/picture-gallery
.git
Cloning into 'picture-gallery'...
Username for 'https://gitlab.com': ji
Password for 'https://ji@gitlab.com':
fatal: Authentication failed for 'https://gitlab.com/clojure-code-examples/pictu
re-gallery.git/'

C:\Users\jiji>

anyway I downloaded source from web and unzip this file

2) I have problem when I write psql -c 'CREATE DATABASE gallery TEMPLATE template0'. I use Windows 7. Though I installed postgresql, 'psql' instruction have not worked in cmd window. I don't know how I can use 'psql' instruction in window. anyway I make gallery database like this

enter image description here

3) and I write lein ring server in cmd window but I got error like this:

C:\Users\jiji\clojureproject\clojure-picture-gallery-master>lein ring server
picture-gallery is starting
Exception in thread "main" org.postgresql.util.PSQLException: The server request
ed password-based authentication, but no password was provided., compiling:(C:\U
sers\jiji\AppData\Local\Temp\form-init366034846235691962.clj:1:105)
        at clojure.lang.Compiler.load(Compiler.java:7142)
        at clojure.lang.Compiler.loadFile(Compiler.java:7086)
        at clojure.main$load_script.invoke(main.clj:274)
        at clojure.main$init_opt.invoke(main.clj:279)
        at clojure.main$initialize.invoke(main.clj:307)
        at clojure.main$null_opt.invoke(main.clj:342)
        at clojure.main$main.doInvoke(main.clj:420)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: org.postgresql.util.PSQLException: The server requested password-base
d authentication, but no password was provided.
        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(Connect
ionFactoryImpl.java:473)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(Conne
ctionFactoryImpl.java:203)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactor
y.java:65)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Conn
ection.java:146)
        at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Conn
ection.java:35)
        at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gC
onnection.java:22)
        at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Conn
ection.java:47)
        at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:30)
        at org.postgresql.Driver.makeConnection(Driver.java:414)
        at org.postgresql.Driver.connect(Driver.java:282)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:208)
        at clojure.java.jdbc$get_connection.invoke(jdbc.clj:177)
        at clojure.java.jdbc$get_connection.invoke(jdbc.clj:161)
        at clojure.java.jdbc$get_connection.invoke(jdbc.clj:164)
        at clojure.java.jdbc$with_connection_STAR_.invoke(jdbc.clj:300)
        at picture_gallery.models.schema$table_exists_QMARK_.invoke(schema.clj:2
8)
        at picture_gallery.models.schema$migrate.invoke(schema.clj:35)
        at picture_gallery.handler$init.invoke(handler.clj:18)
        at clojure.lang.Var.invoke(Var.java:375)
        at ring.server.standalone$serve.doInvoke(standalone.clj:93)
        at clojure.lang.RestFn.invoke(RestFn.java:423)
        at ring.server.leiningen$serve.invoke(leiningen.clj:20)
        at user$eval6633.invoke(form-init366034846235691962.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6703)
        at clojure.lang.Compiler.eval(Compiler.java:6693)
        at clojure.lang.Compiler.load(Compiler.java:7130)
        ... 11 more
Subprocess failed

C:\Users\jiji\clojureproject\clojure-picture-gallery-master>

I guess it is password problem. but I don't know what it means

in short I have three question about 1)),2)),3)) why they are not worked?


Solution

  • answerto question 3)

    take a look at /src/picture_gallery/models/db.clj here https://gitlab.com/dzaporozhets/clojure-picture-gallery/blob/master/src/picture_gallery/models/db.clj#L4

    either set you DATABASE_URL environment variable to contain valid postgres connection url or just use

    (def db (or (System/getenv "DATABASE_URL")
                "postgresql://user:password@localhost:5432/gallery")) 
    

    replace user and password before @localhost with your postgres's user and password