Created
February 12, 2010 13:05
-
-
Save spariev/302538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; make sure you have c3p0 jar in classpath | |
(def *c3p0-datasource* | |
(let [db-config (org.ho.yaml.Yaml/load (java.io.File. "../../config/database.yml")) | |
env-config (get db-config rails-env) ] | |
(doto (com.mchange.v2.c3p0.ComboPooledDataSource.) | |
(.setDriverClass "com.mysql.jdbc.Driver") | |
(.setJdbcUrl (str "jdbc:mysql://" (get env-config "host") "/" (get env-config "database"))) | |
(.setConnectionTesterClassName "com.mysql.jdbc.integration.c3p0.MysqlConnectionTester") | |
(.setIdleConnectionTestPeriod 120) | |
(.setUser (get env-config "username")) | |
(.setPassword (get env-config "username"))))) | |
; and then ... | |
(with-connection {:datasource *c3p0-datasource*} | |
...) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment