On Oct 9, 2008, at 12:06 PM, Luc Prefontaine wrote: > Hi everyone, > > I may look stupid but how do you cast Java arguments ? > > (java.sql.DriverManager/registerDriver (clojure.lang.RT/classForName > "com.mysql.jdbc.Driver")) > java.lang.ClassCastException: java.lang.Class cannot be cast to > java.sql.Driver (NO_SOURCE_FILE:0) > > I fully agree with the error message but how can I change from > Object to java.sql.Driver ? I tried half a dozen ways and > searched on the web site but nothing yet.
Hi Luc, I haven't used registerDriver. It looks like it's intended to be called from within com.mysql.jdbc.Driver to register itself with the manager. In example code I've seen, a *user* of a jdbc driver (as distinguished from a driver implementer) only needs to arrange for the class to be loaded with code like: (clojure/lang.RT/classForName "com.mysql.jdbc.Driver") That has worked for me. You may also find some good info in the source code for 'clojure.contrib.sql which includes an example that uses derby. Please see: http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/src/clojure/contrib/sql/sql.clj?revision=190&view=markup and http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/src/clojure/contrib/sql/test/test.clj?revision=190&view=markup To answer your casting question, Clojure provides some functions along those lines: (find-doc "[Cc]ast|[Cc]oerce") Will show you some docs for them. --Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---