We are using hibernate 3.0, mysql 5 and JBoss 4.0.2. We are using the datasouce that comes from JBoss and a hibernate config file has the following properties:
Code:
<property name="hibernate.connection.datasource">java:/dropDS</property>
<property name="show_sql">false</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.cglib.use_reflection_optimizer">false</property>
<property name="hibernate.connection.release_mode">auto</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">50</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>
Under nice light load, less than 20 concurrent users, all is well. But under a little more load, like 100 concurrent users, we start to see:
Code:
org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (java.sql.SQLException: Data source rejected establishment of connection, message from server: "Too many connections");
We are running a Dual 64 bit XEON server with 2GB Ram. MySQL 5.0 default connections were left at installation defaults - which I believe is 100 connections.
My question is if we are using the Hibernate connection pool facility, how come we are getting "too many connections" problems?
We have gone over our code and looked at everyplace we get a hibernate session and ensure that we close it in a finally block. In addition, we have made sure that no place in our code do we call a session.connection() call.
Also, for an example of one of the places where we see the exception, is not necessarily when we get a new session. Sometimes, we get that same error when we do something like a criteria.list() call.
Ideas? Suggestions?
Thanks in advance,
Mark