Ian Chu Te Ian Chu Te - 4 months ago 11
Java Question

How to change Leiningen dependency tree

I am using [korma "0.4.0"] in my project.

And this version of Korma, by default, uses c3p0-​0.9.1.2

According to this SO post, I need c3p0-​0.9.5.1​ to be able to use

createArrayOf
on a
NewProxyConnection
. I'm doing this because I need to be able to insert PostGre SQL arrays.

For the purpose of completeness, my code used to convert from a Clojure vector to an SQL Array object in Java is the following:

(.createArrayOf
(-> db get-connection :datasource .getConnection)
"varchar"
(into-array String someVector)
)


Also, the error I am getting is:


Exception in thread "main" java.lang.AbstractMethodError:
com.mchange.v2.c3p0.impl.NewProxyConnection.createArrayOf


Which is the same as the error mentioned in that same SO post I mentioned above.

How do I alter the dependency tree such that Korma is forced to use c3p0-​0.9.5.1 instead of c3p0-​0.9.1.2​?

Answer

in your project.clj, ask for the version which you need, and for good measure it's often helpful to exclude the dependency from the project which asks for the wrong version.

:dependencies [[com.mchange/c3p0 "0.9.5.1"]
               [korma "0.4.2"
                :exclusions [c3p0]]]

The dependency resolver will respect top level dependencies over nested ones, and :exclusions will prevent the version asked for by a specific dep from being used.

Comments