Pool connection pool C3P0
I have a web application that uses c3p0 as its connection pool. we are using hibernate as orm tool. We've been getting connection timeout exceptions lately. To debug this exception, I enabled C3p0 logging and got some information in the logs. Can anyone help me to fully understand this.
DEBUG 2012-08-05 14:43:52,590 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] com.mchange.v2.c3p0.stmt.GooGooStatementCache: checkinAll(): com.mchange.v2.c3p0.stmt.GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
From the above, I can see that the total size of the connection pool is 2. The number of connections checked is 0. Is this correct? And what are num_connections and num keys in the above?
Thank..
source to share
What you see in the log bit that you specified is a snapshot of the Statement cache, not a connection pool. At the time of posting this message, there were two cached PreparedStatements that belonged to the same connection. None of the statements have been verified / used.
Hope this helps!
source to share
Exceptions can be caused by incorrect definition of C3P0 settings. Make sure you link to the right jar file. Your application must be linked to "hibernate-c3p0 * .jar", not "c3p0 * .jar". The hibernate.cfg file must have a property hibernate.connection.provider_class
defined for the c3p0 settings to take effect. Below are examples of settings
<property name="hibernate.connection.provider_class"> org.hibernate.connection.C3P0ConnectionProvider </property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
The log entry states that there are 4 connections in the pool and all 4 connections are available to the application. Running a query against your database to display all active connections displays pool connections. For example, in Mysql, you can run " show processlist;
" to see these connections.
source to share