On Fri, Oct 10, 2008 at 11:45 AM, mritun <[EMAIL PROTECTED]> wrote:
>
> On Oct 10, 1:46 am, Luc Prefontaine <[EMAIL PROTECTED]>
> wrote:
[...]
>> The mysql jdbc driver code says that it registers itself (static block)
>> but something is wrong.
>> Eventually I will find why but now I have other pressing needs to full
>> fill than debugging that code.
>
> Static blocks don't execute until the class is loaded, so just
> specifying a class in classpath is not enough.
>
> In Java the idiomatic way to let the driver initialize itself, is to
> add the following line somewhere in your initialization code before
> requesting connection:
>
> Class.forName("com.mysql.jdbc.Driver");
>
> This loads the class, and its static block registers the driver. You'd
> have to do an equivalent in clojure too.

How about this then (as hinted at by Stuart Halloway):

user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
nil
user=> (java.sql.DriverManager/registerDriver
  (.newInstance (clojure.lang.RT/classForName "com.mysql.jdbc.Driver")))
nil
user=> (enumeration-seq (. java.sql.DriverManager getDrivers))
([EMAIL PROTECTED] [EMAIL PROTECTED])

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to