0

I am using Clojure jdbc and c3p0 for connection pooling.

Before running any query and startting of application it prints out a message as follows to the console.

Jul 11, 2016 6:22:48 PM com.mchange.v2.log.MLog 
INFO: MLog clients using java 1.4+ standard logging.
Jul 11, 2016 6:22:48 PM com.mchange.v2.c3p0.C3P0Registry 
INFO: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]

Jul 11, 2016 6:22:48 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource 
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> z8kflt9h1ohpn8xry5id4|663c9e7a, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> z8kflt9h1ohpn8xry5id4|663c9e7a, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:postgresql://localhost:5432/postgres, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 10800, maxIdleTimeExcessConnections -> 1800, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]

Is there any way to turn this off, for example while specifying the datasource?

(defn pool
  [spec]
  (let [cpds (doto (ComboPooledDataSource.)
               (.setDriverClass (:classname spec))
               (.setJdbcUrl (str "jdbc:" (:subprotocol spec) ":" (:subname spec)))
               (.setUser (:user spec))
               ;; expire excess connections after 30 minutes of inactivity:
               (.setMaxIdleTimeExcessConnections (* 30 60))
               ;; expire connections after 3 hours of inactivity:
               (.setMaxIdleTime (* 3 60 60)))]
    {:datasource cpds}))

Also had the following in my code.

(defn -main
  "JDBC CS425 Assignment."
  [path]
  (System/setProperties
   (doto (java.util.Properties. (System/getProperties))
     (.put "com.mchange.v2.log.MLog" "com.mchange.v2.log.FallbackMLog")
     (.put "com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL" "OFF")))
  ;;(check-for-tables pooled-db path)
  (run-queries))
Sanchayan Maity
  • 637
  • 6
  • 19
  • Possible duplicate of [how do I turn off logging in java c3p0 connection pooling lib?](http://stackoverflow.com/questions/2976308/how-do-i-turn-off-logging-in-java-c3p0-connection-pooling-lib) – kongeor Jul 11 '16 at 13:11
  • I have seen that link and also tried the Clojure solution one of the guys posted at the end. Did not work for me. – Sanchayan Maity Jul 11 '16 at 13:19
  • Hi. In whatever you log to, just set logging for loggers `com.mchange.*` to a more restrictive level (`WARNING` is best). Turning logging off entirely -- what you are trying to do, but hitting an initiation race -- is a bad idea. – Steve Waldman Jul 20 '16 at 00:50

0 Answers0