On Apr 27, 2009, at 6:19 AM, Mark Derricutt wrote:

Hey guys,

Just started looking at clojure-contrib's sql namespace, however, using the following code:

(let [user_id (.toString (java.util.UUID/randomUUID))]
  (sql/with-connection db (sql/insert-records
    :users
    {:user_id user_id})))

That code looks right to me. What is the definition of the users table? Could you please post a minimal complete example that shows the problem?

and clojure-contrib-1.0-20090421.092453-8.jar seems to generate:

java.lang.Exception: transaction rolled back: Batch entry 0 INSERT INTO users (user_id) VALUES (c3583933-cc55-4007-b857-b24441cfe409) was aborted. Call getNextException to see the cause. at clojure.contrib.sql.internal $transaction_STAR___4079.invoke(internal.clj:95)
        at clojure.contrib.sql$do_prepared__4108.doInvoke(sql.clj:87)
        at clojure.lang.RestFn.applyTo(RestFn.java:144)

I don't think quotes are the problem, but they could be.

The exception message mentions calling "getNextException" (a method on SQLException) to see the cause. If you're working at the repl, you can do that with:

        (.getNextException *e)

As a result of your report, I'm working on adding better error reporting on BatchUpdateException and SQLException to clojure.contrib.sql. It would be helpful to have your example as a test case.


--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to