diff --git a/CHANGELOG.md b/CHANGELOG.md index fc4e1ed..610201d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Only accretive/fixative changes will be made from now on. The following changes have been committed to the **master** branch since the 1.0.2 release: -* Address #48 by adding `next.jdbc.connection/jdbc-url` and showing HikariCP and c3p0 connection pooling (so far it's just tests). +* Address #48 by adding `next.jdbc.connection/->pool` and showing HikariCP and c3p0 connection pooling (so far it's just tests). ## Stable Builds diff --git a/src/next/jdbc/connection.clj b/src/next/jdbc/connection.clj index 23107f0..ba043f2 100644 --- a/src/next/jdbc/connection.clj +++ b/src/next/jdbc/connection.clj @@ -192,7 +192,7 @@ (throw (ex-info (str "Unknown dbtype: " dbtype) db-spec))) [url etc])) -(defn jdbc-url +(defn ->pool "Given a connection pooling class and a database spec, return an connection pool object built from the database spec." [clazz db-spec] diff --git a/src/next/jdbc/specs.clj b/src/next/jdbc/specs.clj index a5dbd67..1b85851 100644 --- a/src/next/jdbc/specs.clj +++ b/src/next/jdbc/specs.clj @@ -114,7 +114,7 @@ :opts (s/? ::opts-map))) :body (s/* any?))) -(s/fdef connection/jdbc-url +(s/fdef connection/->pool :args (s/cat :clazz #(instance? Class %) :db-spec ::db-spec-map)) @@ -192,7 +192,7 @@ `jdbc/execute-one! `jdbc/transact `jdbc/with-transaction - `connection/jdbc-url + `connection/->pool `prepare/execute-batch! `prepare/set-parameters `sql/insert! diff --git a/test/next/jdbc/connection_test.clj b/test/next/jdbc/connection_test.clj index d10a08c..8c02344 100644 --- a/test/next/jdbc/connection_test.clj +++ b/test/next/jdbc/connection_test.clj @@ -106,10 +106,10 @@ (with-open [con (p/get-connection db {})] (is (instance? java.sql.Connection con)))) (testing "connection via HikariCP" - (with-open [con (p/get-connection (c/jdbc-url com.zaxxer.hikari.HikariDataSource db) + (with-open [con (p/get-connection (c/->pool com.zaxxer.hikari.HikariDataSource db) {})] (is (instance? java.sql.Connection con)))) (testing "connection via c3p0" - (with-open [con (p/get-connection (c/jdbc-url com.mchange.v2.c3p0.ComboPooledDataSource db) + (with-open [con (p/get-connection (c/->pool com.mchange.v2.c3p0.ComboPooledDataSource db) {})] (is (instance? java.sql.Connection con))))))