Next.jdbc applying defaults on transaction causes execute-batch! to fail when using c3p0 connection pool

(def connection-params {...})
(def default-options {...})
(def ds (connection/->pool ComboPooledDataSource connection-params))

(jdbc/with-transaction [tx ds]
  (let [wrapped-ds (jdbc/with-options tx default-opts)]
     (jdbc/execute-batch! wrapped-ds "INSERT INTO TEST_TAB (id) VALUES (?)" (->> (range 10) (map [#(assoc](#hashtag) {} :id %))) {})))

Results in error when execute-batch! is called:
No implementation of method: :get-datasource of protocol: [next.jdbc.protocols/Sourceable] found for class: com.mchange.v2.c3p0.impl.NewProxyConnection

Is this expected and is there a workaround?

Not expected. I think I know what is causing it, but if that’s the case I would have expected this to fail with a plain connection as well [Update: I was wrong! :slight_smile: ]

I have created issue #181 on github.com to track this (I figured out the bug and have a solution in testing).

OK, this is fixed and you can either try it out via a git dep or as 1.2.999-SNAPSHOT (every push to the repo pushes a new snapshot to Clojars).

2 Likes

Hi Sean, thank you for the quick response.

This seems to work for the transaction case for us but seems to have broken the plain connection:

  actual: java.lang.IllegalArgumentException: No implementation of method: :prepare of protocol: #'next.jdbc.protocols/Preparable found for class: com.mchange.v2.c3p0.ComboPooledDataSource

Could you please take a look at this also? Thanks!

Dang, sorry. OK, updated SNAPSHOT available to test.

Great - thank you, testing and working now :slight_smile: Do you have a date for the next release in which this will be included, at all?

I can probably cut a release today. I’ll try to remember this afternoon.

That would be great - thank you so much for the prompt response and solution

1.2.731 is available on Clojars.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.