java.jdbc

using exisiting java based connection pool in clojure

Details

  • Type: Enhancement Enhancement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

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))
)
)

Activity

Hide
Sean Corfield added a comment -

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.

Show
Sean Corfield added a comment - 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.
Hide
Sean Corfield added a comment -

I'll close this out then Amir, thanx.

Show
Sean Corfield added a comment - I'll close this out then Amir, thanx.
Hide
Amir added a comment -

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.

Show
Amir added a comment - 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.
Hide
Sean Corfield added a comment -

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

Show
Sean Corfield added a comment - Amir, have you had a chance to try my suggestion?
Hide
Sean Corfield added a comment -

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.

Show
Sean Corfield added a comment - 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.
Hide
Amir added a comment -

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)

Show
Amir added a comment - 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)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: