Fork me on GitHub

can anyone recommends me a JDBC connection pool? im having strange issues using c3p0 like msgs `com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet successfully received from the server was 125,692 milliseconds ago. The last packet sent successfully to the server was 7 milliseconds ago.`


@plins We use c3p0 in production and have no problems -- but you have to configure it properly.


Which database are you using?


anywhere where i could find some good production examples?


right now i think im going with the defaults


Here's the configuration we use in production -- the main thing to look at are your timeouts for idle and test connections

cpds    (doto (ComboPooledDataSource.)
                      (.setDataSourceName dsn-name)
                      (.setDriverClass "com.mysql.jdbc.Driver")
                      (.setJdbcUrl jdbc-url)
                      (.setUser user)
                      (.setPassword password)
                      ;; pool size (default is 3 and 15):
                      (.setMinPoolSize min-pool)
                      (.setMaxPoolSize max-pool)
                      (.setNumHelperThreads num-helpers)
                      ;; initial pool size default is 3 but actual pool size
                      ;; must be between minimum and maximum pool size
                      (.setInitialPoolSize min-pool)
                      ;; expire excess connections after 10 mins of inactivity:
                      (.setMaxIdleTimeExcessConnections (* 10 60))
                      ;; expire connections after 61 minutes of inactivity:
                      (.setMaxIdleTime (* 61 60))
                      ;; idle connection testing
                      (.setAutomaticTestTable "c3p0connection")
                      (.setTestConnectionOnCheckin true)
                      (.setIdleConnectionTestPeriod (* 11 60))
                      ;; unreturned (app leakage) get zapped after an hour:
                      (.setUnreturnedConnectionTimeout (* 59 60)))]


@plins also, generally, when hitting a problem like this I’ve had the most success with googling how to address the issue in java - the translation to clojure is always trivial and the problems are identical


MySQL also has an issue that if you don't explicitly time things out it messes up connections after eight hours I believe (we hit that initially before we added all those timeouts).


(I’ve also used c3p0 with no issue)


But we've had this configuration in production for years now with heavy traffic -- powering over 100 dating sites with millions of users 🙂


thanks everybody for the comments 🙂


100 dating sites? Must be get pretty niche


It's an... interesting... business to be in. With some very specific data challenges at times 🙂


huh, interesting