Jboss, Remote EJB, Swing and Mysql.

I have a EJB 3.0 of session in JBoss. This Ejb connect with Mysql with Hibernate. I consume this EJB with a Swing app.

When you run it, it make a session ejb, connect to Mysql, Extract data and disconnect. In each call to this, it keep a connection opened In Mysql (Sleep) and a thread on Jboss opened.

Mysql crash beacause it keep to many connections opened. JBoss crash beacuse it have to many threads opened.

When swing disconnect from JBoss, why it not clase Mysql connection and delete thread of JBoss?

######### HIBERNATE ########
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-configuration ...>
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MyS QLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql .jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">pass</property>
<property name="hibernate.current_session_context_class">org .hibernate.context.ThreadLocalSessionContext</property>
<!-- <property name="hibernate.show_sql">true</property>
<property name="org.hibernate.SQL">DEBUG</property>
<property name="org.hibernate">DEBUG</property>
-->
<property name="hibernate.c3p0.timeout">100</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.maxIdleTime">120</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<mapping resource="DB/conf/Empresa.hbm.xml" />
</session-factory>
</hibernate-configuration>