Skip to content
/ hikari-cp Public
forked from tomekw/hikari-cp

A Clojure wrapper to HikariCP JDBC connection pool

License

Notifications You must be signed in to change notification settings

devn/hikari-cp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hikari-cp

hikari-cp

A Clojure wrapper to HikariCP - "zero-overhead" production ready JDBC connection pool.

Future plans

  • I'm still learning Clojure and this is my first public project in this language
  • Add proper documentation
  • Write tests
  • Use Prismatic/schema to validate the configuration options
  • Handle configuration errors
  • (Probably) learn to write more idiomatic Clojure
  • Support Heroku's DATABASE_URL with datasource-from-url

I won't be available on-line until 08.09.2014!

Installation

Add the following dependency to your project.clj file:

[hikari-cp "0.2.0"]

Usage

(ns hikari-cp.example
  (:require [hikari-cp.core :refer :all]
            [clojure.java.jdbc :as jdbc]))

(def config {:auto-commit           true
             :read-only             false
             :connection-timeout    30000
             :idle-timeout          600000
             :max-lifetime          1800000
             :datasource-class-name "org.postgresql.ds.PGSimpleDataSource"
             :minimum-idle          10
             :maximum-pool-size     10
             :username              "username"
             :password              "password"
             :database-name         "database"
             :server-name           "localhost"
             :port                  5432
             })

(def ds-config (datasource-config config))

(def datasource
  (datasource-from-config ds-config))

(defn -main [& args]
  (jdbc/with-db-connection [conn {:datasource datasource}]
    (let [rows (jdbc/query conn "SELECT * FROM table")]
      (println rows)))
  (close-datasource datasource))

License

Copyright © 2014 Tomek Wałkuski

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A Clojure wrapper to HikariCP JDBC connection pool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published