Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
;; make sure you have c3p0 jar in classpath
(def *c3p0-datasource*
(let [db-config (org.ho.yaml.Yaml/load ( "../../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
You can’t perform that action at this time.