+1
On May 9, 2:33 am, Mark Derricutt <m...@talios.com> wrote:
> Hi,
>
> Can we add the following to contrib's sql namespace, it simply adds "jndi"
> as a db-spec scheme ( I also raised this
> ashttp://code.google.com/p/clojure-contrib/issues/detail?id=39, which google
> decided to set as a defect and I can't change):
>
> Index: src/clojure/contrib/sql/internal.clj
> ===================================================================
> --- src/clojure/contrib/sql/internal.clj (revision 776)
> +++ src/clojure/contrib/sql/internal.clj (working copy)
> @@ -56,17 +56,19 @@
> :subprotocol (required) a String, the jdbc subprotocol
> :subname (required) a String, the jdbc subname
> (others) (optional) passed to the driver as properties."
> - [{:keys [datasource username password classname subprotocol subname]
> + [{:keys [jndi datasource username password classname subprotocol subname]
> :as db-spec}]
> (when classname
> (clojure.lang.RT/loadClassForName classname))
> - (if datasource
> - (if username
> - (.getConnection datasource username password)
> - (.getConnection datasource))
> - (java.sql.DriverManager/getConnection
> - (format "jdbc:%s:%s" subprotocol subname)
> - (as-properties (dissoc db-spec :classname :subprotocol :subname)))))
> + (if jndi
> + (.getConnection (.lookup (javax.naming.InitialContext.) jndi))
> + (if datasource
> + (if username
> + (.getConnection datasource username password)
> + (.getConnection datasource))
> + (java.sql.DriverManager/getConnection
> + (format "jdbc:%s:%s" subprotocol subname)
> + (as-properties (dissoc db-spec :classname :subprotocol
> :subname))))))
>
> (defn with-connection*
> "Evaluates func in the context of a new connection to a database then
>
> --
> Discouragement is a dissatisfaction with the past, a distaste for the
> present, and a distrust of the future - Maree De Jong, Life
> NZ.http://www.talios.com
--~--~---------~--~----~------------~-------~--~----~
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
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---