Saduações,
Estou com problemas para configurar meu pool de conexoes no hibernate.
configurei tudo como está aqui
[url]https://www.hibernate.org/114.html[/url] no site do proprio hibernate.
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Settings for a local HSQL (testing) database. -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://127.0.0.1:3306/pool</property>
<property name="connection.username">rot</property>
<property name="connection.password"></property>
<!-- Use the C3P0 connection pool. -->
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">100</property> <!-- seconds -->
<property name="c3p0.max_size">100</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.timeout">100</property> <!-- seconds -->
<property name="c3p0.initialPoolSize">15</property> <!-- seconds -->
<!-- DEPRECATED very expensive property name="c3p0.validate>-->
<!-- Disable second-level cache.
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="cache.use_query_cache">false</property>
<property name="cache.use_minimal_puts">false</property>
<property name="max_fetch_depth">3</property> -->
<!-- Print SQL to stdout. -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<!--
Drop and then re-create schema on SessionFactory build, for testing.
-->
<property name="hbm2ddl.auto">create</property>
<!-- Bind the getCurrentSession() method to the thread. -->
<property name="current_session_context_class">thread</property>
<!--
Hibernate XML mapping files <mapping resource="org/MyClass.hbm.xml"
/>
-->
<!--
Hibernate Annotations (and package-info.java) <mapping
package="com.poolproject.model" /> <mapping
class="com.poolproject.model.Pessoa" />
-->
</session-factory>
</hibernate-configuration>
public class HibernateListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
System.out.println(">INICIANDO CONTEXTO");
HibernateUtil.getSessionFactory(); // Just call the static initializer
// of that class
}
public void contextDestroyed(ServletContextEvent event) {
HibernateUtil.getSessionFactory().close(); // Free all resources
}
}
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure()
.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
Detalhe que eu coloquei meu usuario incorreto na conexao, e mesmo assim tá funcionando =/.
Qdo abre o Administrador no mysql , nao aparece nenhum conexao aberta.
Alguém sabe o que pode ser o problema?
Valeu galera.