Hibernate version: 3
Code between sessionFactory.openSession() and session.close(): various
Name and version of the database you are using: MySQL 5.0.67
I wrote a web application in JSF that uses Hibernate as a persistence layer. This is a web-based "front end" for a database, so it communicates with the db server extensively. It is being run on Apache Tomcat.
My problem is that it creates enormous amounts of connections (which can be viewed as "connection threads" in the MySQL Administrator under 'Server Connections'). The connections disappear after a single session of the application makes use of them several times, so when a single user is using the application, there is no problem. But when several people use the application at the same time, the number of active connections grows quickly and in the end exceeds the allowed maximum. I get a DDoS...
I've tried to find a solution to this problem for some time, but haven't succeeded. I cannot find any way to limit the number of the connections that the application establishes with the database server.
Below is a part of my hibernate.cfg.xml file with the configuration of the db connection.
Code:
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">***</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ies_dbo?useUnicode=true&characterEncoding=UTF-8</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.max_size">1</property>
<property name="hibernate.c3p0.timeout">100</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>