<< Back to previous view

[JDBC-36] using exisiting java based connection pool in clojure Created: 24/Jul/12  Updated: 01/Jun/16  Resolved: 12/Aug/12

Status: Closed
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Amir Assignee: Sean Corfield
Resolution: Declined Votes: 0
Labels: None


We have a connection pool in Java and would like to use the same for our complete project where code is mixture of Clojure/Java.

(def db (ConnectionManager/getConnection)) ; #<ConnectionHandle com.jolbox.bonecp.ConnectionHandle@53371566> connection type we get after excuting this line
sql/with-connection db
(sql/with-query-results res ["select * from DummyTable where rownum <=100"] (vec res)
(map #(println (class (val %)) " " (key %)) (first res))

Comment by Amir [ 24/Jul/12 3:00 AM ]

If we execute the above (with connection - with-query results) i get the following exception

IllegalArgumentException db-spec com.jolbox.bonecp.ConnectionHandle@53371566 is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:192)

Comment by Sean Corfield [ 24/Jul/12 12:34 PM ]

Use the :datasource option to define your db-spec:

(def db {:datasource bonecpDataSourceObject})

I looked at the BoneCP docs and I don't see a ConnectionManager class but if you define the db-spec based on the BoneCPDataSource object, java.jdbc will call getConnection on that object to get a working connection for operations.

Comment by Sean Corfield [ 31/Jul/12 7:49 PM ]

Amir, have you had a chance to try my suggestion?

Comment by Amir [ 01/Aug/12 2:20 AM ]

Hi Sean,

No, we moved to clojure based pooling in a while. We thought its better to have all stuff in clojure rather than having java+clojure. But i can give it a try today.

Thanks for your suggestion. will keep you posted.

Comment by Sean Corfield [ 12/Aug/12 9:35 PM ]

I'll close this out then Amir, thanx.

Comment by Sean Corfield [ 12/Aug/12 9:36 PM ]

I believe there is a way to access the the BoneCP connection pool directly and use it with java.jdbc as-is, however it is no longer an issue for the creator of this ticket.

Generated at Mon Apr 22 23:03:45 CDT 2019 using JIRA 4.4#649-r158309.