0
I configured C3P0 via persistence.xml, however, when I try to recover the configuration values via Combopooleddatasource the received values are different from what was configured in the configuration file.
<properties>
<!-- Configurações específicas do Hibernate -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- Propriedades JDBC -->
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/financas" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="123" />
<property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.min_size" value="10" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.timeout" value="1800" />
<property name="hibernate.c3p0.minPoolSize" value="10"/>
<property name="hibernate.c3p0.maxPoolSize" value="20"/>
</properties>
And in java:
EntityManager em = JPAUtil.getEntityManager();
ComboPooledDataSource ds = new ComboPooledDataSource();
System.out.println("Numero de conexoes: " + ds.getMaxPoolSize());
I believe that the value returned by getMaxPoolSize() should be 20, but is returning 15.
What now? how to load persistence.xml settings in Combopooleddatasource?
----------------- UPDATED ---------
I added the properties :
<property name="hibernate.c3p0.minPoolSize" value="10"/>
<property name="hibernate.c3p0.maxPoolSize" value="20"/>
But java keeps returning maxPoolSize = 15 and now?
tries to add
<property name="hibernate.c3p0.max_statements" value="20" />
– brow-joe
You can also set directly by pool,
ds.setMinPoolSize(10);
ds.setMaxPoolSize(20);
– brow-joe