Welcome! Please see the About page for a little more info on how this works.

+4 votes
in java.data by
edited by

Some Java classes expect arguments of the type java.util.Properties, for example HikariCP. Currently I need to construct these manually:

     (doto (java.util.Properties.)
       (.putAll {"socketTimeout" "30" }))}

it would be nice if I could instead just provide a map and it got converted to Properties automatically:

{:dataSourceProperties {"socketTimeout" "30" }}

Properties is a built-in JVM class used regularly to it seems fitting to have built-in support for it.

Adding something like this would suffice:

(defmethod j/to-java [java.util.Properties clojure.lang.APersistentMap] [_ props]
  (doto (java.util.Properties.) (.putAll props)))

1 Answer

+1 vote
selected by
Best answer

Great idea!

Created in Jira as https://clojure.atlassian.net/browse/JDATA-22 -- will update this post when it is implemented.

This has been released in 1.0.92 -- I'll be updating `next.jdbc` shortly to depend on that and include it in the documentation.
next.jdbc 1.2.737 is out. Docs have been updated to include an example based on this that uses java.data to create the properties object.