ProductPromotion
Logo

Clojure

made by https://0x3d.site

GitHub - metabase/connection-pool: Connection pools for JDBC databases. Simple wrapper around C3P0.
Connection pools for JDBC databases. Simple wrapper around C3P0. - metabase/connection-pool
Visit Site

GitHub - metabase/connection-pool: Connection pools for JDBC databases. Simple wrapper around C3P0.

GitHub - metabase/connection-pool: Connection pools for JDBC databases. Simple wrapper around C3P0.

Downloads Dependencies Status Circle CI License cljdoc badge

Clojars Project

Creating a Connection Pool

From a clojure.java.jdbc spec

You can create a C3P0 connection pool with any clojure.java.jdbc connection spec map with :subname and :subprotocol keys. connection-pool-spec will return a clojure.java.jdbc connection spec you can use directly:

(require '[clojure.java.jdbc :as jdbc]
         '[metabase.connection-pool :as connection-pool])

;;; Create a C3P0 connection pool

(let [pool-spec (connection-pool/connection-pool-spec my-jdbc-spec)]
  (jdbc/query pool-spec ["SELECT *"]))

(You will almost certainly want to store your pool somewhere, such as in an atom).

From a JDBC URL String:

You can create a pooled DataSource (e.g., for use with next-jdbc) by calling pooled-data-source-from-url:

(require '[next.jdbc :as jdbc]
         '[metabase.connection-pool :as connection-pool])

(with-open [connection (jdbc/get-connection (connection-pool/pooled-data-source-from-url "jdbc:postgresql:localhost:3000/my_db"))]
  (reduce my-fn init-value (jdbc/plan connection ["SELECT *"])))

Configuring the connection pool

You can set connection pool options such as size in a c3p0.properties file, or by passing them as a map to connection-pool-spec:

(def ^:private connection-pool-properties
  {"maxIdleTime"     (* 3 60 60)
   "minPoolSize"     1
   "initialPoolSize" 1
   "maxPoolSize"     15})

(def my-pool-spec
  (connection-pool/connection-pool-spec my-jdbc-spec connection-pool-properties))

See https://www.mchange.com/projects/c3p0/#configuration_properties for a list of all options.

Destroying connection pools

destroy-connection-pool! will destroy the connection pool you created:

(connection-pool/destroy-connection-pool! pool-spec)

Legal Stuff

Copyright © 2019 Metabase, Inc. This project is licensed under the Eclipse Public License, same as Clojure.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory