Thanks, Brian,It looks like there's a problem with the arguments to with-query- results. I recently changed with-query-results to accept/expect the query as a vector containing a string and params rather than just a string. Here's a correct call to with-query-results for the currently checked in clojure.contrib.sql (note the second argument to with-query- results):
(defn db-read "Read the entire fruit table" [] (sql/with-connection db (sql/with-query-results res ["SELECT * FROM fruit"] (doseq [rec res] (println rec)))))In the stack trace you sent, I see "com.yourcompany.defpackage" mentioned as the namespace for the db-read you're using. It may not be exactly the same as the one in clojure.contrib.sql.test. I'd like to see yours.
Could you please see if you can duplicate the problem using fresh SVN checkouts of Clojure and clojure-contrib? Please use a test program that is exactly the same as "clojure/contrib/sql/test.clj" except for db pointing to your SQL Server/MS jdbc database?
It would also be helpful if you can run this test under Java 6 because ClassCastExceptions in Java 6 mention the "from" and "to" types for the failed cast in the message for the exception. I'd like to see that.
Thanks, --Steve On Jan 26, 2009, at 11:01 AM, BrianS wrote:
Steve, Thanks for the reply, here is the error stack trace I retrieved when running the code from clojure.contrib.sql. The actual function I was running was "db-read", and the stack trace can be found at http://clojure.pastebin.com/f660e0aac . Thanks, Brian On Jan 26, 10:25 am, "Stephen C. Gilardi" <squee...@mac.com> wrote:Hi Brian, Could you please paste a copy of the stack trace for the ClassCastException you're seeing tohttp://clojure.pastebin.comand post the URL for it here? If you're driving your program at the repl, you can get a stack trace from the most recent exception with: (.printStackTrace *e) Thanks, --Steve On Jan 26, 2009, at 9:45 AM, BrianS wrote:I have been able to connect up clojure and my SQL Server 2005 server, using the sample code include with clojure-contrib, at least in terms of connecting, and responding to command like CREATE TABLE and INSERTINTO. However, whenever I use the commands to access the tables and pull back results (simple SELECT * type SQL commands), I invariably get java.lang.ClassCastException errors. It is not related to NULL values in a field, nor is it related to real or int fields (as I get these errors even when the tables I pull from do not have these types). Has anyone come across this issue with SQL Server/MS JDBC/ clojure-contrib? Barring that, is there anyone with any type of working code example for using clojure-contrib against SQL Server? Thanks in advance for your help, Brian Ssmime.p7s 3KViewDownload--~--~---------~--~----~------------~-------~--~----~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 -~----------~----~----~----~------~----~------~--~---
smime.p7s
Description: S/MIME cryptographic signature