Hey folks, I was using clojure.contrib.sql and found myself needing to create connection strings with several parameters, e.g.,
(def *dbcon* (connection "jtds:sqlserver" "//dbserver.foo.com/MY_DB;instance=dev;user=tree;password=flubber")) I modified the connection function to optionally take a map of parameters: (def *dbcon* (my-connection "jtds:sqlserver" "//dbserver.foo.com/MY_DB" { :instance "dev" :user "tree" :password "flubber"})) The diff is: Index: sql.clj =================================================================== --- sql.clj (revision 181) +++ sql.clj (working copy) @@ -21,8 +21,16 @@ (defn connection "Attempts to get a connection to a database via a jdbc URL" - [subprotocol db-name] - (DriverManager/getConnection (format "jdbc:%s:%s" subprotocol db-name))) + [subprotocol db-name & props] + (let [make-props (fn [args] + (if args + (apply str ";" (interpose ";" + (map #(str (name %1) "=" (%1 args)) + (keys args)))) + ""))] + (DriverManager/getConnection (format "jdbc:%s:%s%s" + subprotocol db-name + (make-props (first props)))))) (defmacro with-connection "Evaluates body in the context of a connection to a database. Any updates If you want to integrate this into contrib, I have a CA ready to go in the mail to Rich. Thanks, -tree -- Tom Emerson [EMAIL PROTECTED] http://www.dreamersrealm.net/~tree --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---