we created an application using RapidclipseX and using PostgreSQL as a database. Below was my initial setting of peristance.xml.
property name="hibernate.hbm2ddl.auto" value="none" />
<property name="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE" />
<property name="hibernate.c3p0.max_size" value="50000" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.max_statements" value="100" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL95Dialect" />
<property name="hibernate.cache.use_query_cache" value="true" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.default_schema" value="canavans" />
<property name="rap.queryCache.mode" value="ENABLE_SELECTIVE" />
<property name="hibernate.archive.autodetection" value="" />
<property name="hibernate.cache.use_second_level_cache" value="true" />
<property name="hibernate.c3p0.timeout" value="3000" />
<property name="hibernate.transaction.auto_close_session" value="false" />
<property name="hibernate.javax.cache.uri" value="classpath:ehcache.xml" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jcache.JCacheRegionFactory" />
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.auto_quote_keyword" value="true" />
<property name="hibernate.globally_quoted_identifiers" value="true" />
When we went on production, we started to get an error: " acquire test – the pool is already maxed out."
Then I added these 2 lines:
<property name="hibernate.c3p0.unreturnedConnectionTimeout" value="120" />
<property name="hibernate.c3p0.debugUnreturnedConnectionStackTraces" value="true" />
For some time, it solved our issue. But now, after we imported the old database, we started to get a new error:
2020-11-25 16:44:11 DEBUG DefaultConnectionTester:207 - Testing a Connection in response to an Exception:
org.postgresql.util.PSQLException: This connection has been closed.
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.handleAndClearWarnings(SqlExceptionHelper.java:299)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logAndClearWarnings(SqlExceptionHelper.java:269)
2020-11-25 16:44:11 DEBUG NewPooledConnection:207 - com.mchange.v2.c3p0.impl.NewPooledConnection@614f3f61 invalidated by Exception.
when I google for the problem, I found that: the solution for the Maxed out the problem that I've implemented (those 2 lines) can be the problem for the new exceptions.
I've also found the connection leak problem. I tried to close entityManager in DAOs, but when I add any JPA-SQL Query and load the Java file, those lines disappear.
Please help me how to solve this issue once and for all. Is there is any efficient way to do this? We have to restart our application on production again and again.
I really appreciate any help you can provide.