I'm trying to use the sql contrib library to connect to a Postgres
database. It's not clear to me how to specify a username and password.
Here's what I'm trying.
(use 'clojure.contrib.sql)
(let [db-host "localhost"
db-name "ct"
db-port 5432
subname (str "//" db-host ":" db-port "/" db-name)]
(println "subname =" subname)
(def db {:classname "org.postgresql.Driver" ; must be in classpath
:subprotocol "postgresql"
:subname subname
:username "mvolkmann"
:password ""})
(with-connection db
(with-query-results rs ["select * from ElementType"]
(println rs))))
The error I get is "org.postgresql.util.PSQLException: FATAL: no
PostgreSQL user name specified in startup packet". I think the problem
is that the username and password values in db aren't used by
with-connection unless a DataSource object is specified. However, it
doesn't seem like I should have to create one of those just to connect
to a relational database. Any idea what I'm doing wrong?
--
R. Mark Volkmann
Object Computing, Inc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---