<< Back to previous view

[JDBC-58] get-connection returns an error Created: 24/May/13  Updated: 24/May/13  Resolved: 24/May/13

Status: Resolved
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Salil Wadnerkar Assignee: Sean Corfield
Resolution: Declined Votes: 0
Labels: None
Environment:

PostgreSQL



 Description   

My db-spec is:
(def db-spec {:classname "org.postgresql.Driver"
:subprotocol "postgresql"
:subname "sd_ventures_development"
:user "sd_ventures"
:password ""})

When I query using the old API:
(defn get-devices []
(jdbc/with-connection db-spec
(jdbc/with-query-results rs ["SELECT * FROM devices"]
(doall rs))))

it works and I get the list of devices.

With the new API -
(defn get-devices []
(let [conn (jdbc/get-connection db-spec)]
(jdbc/query conn ["SELECT * FROM devices"])))
it returns an error:
Exception: java.lang.IllegalArgumentException: db-spec org.postgresql.jdbc4.Jdbc4Connection@4c54daa9 is missing a required parameter
jdbc.clj:221 clojure.java.jdbc/get-connection
jdbc.clj:628 clojure.java.jdbc/db-with-query-results*

I am completely bowled over by this error. I checked the source code. It should never reach that statement in get-connection because I am supplying both subname and subprotocol.



 Comments   
Comment by Sean Corfield [ 24/May/13 11:10 AM ]

Not a bug. You are using the API incorrectly. query takes a db-spec NOT a connection:

(jdbc/query db-spec ["SELECT * FROM devices"])

Generated at Thu Jul 31 21:07:44 CDT 2014 using JIRA 4.4#649-r158309.