<!--как только переполнится пул коннектов, укажем, сколько соединений ещё добавить в пул--> <property name="hibernate.c3p0.acquire_increment">2</property> <!--как долго ждать, чтобы подтвердить соединение, т.е. не закрывать его, а, например, сделать запрос "select 1"--> <property name="hibernate.c3p0.idle_test_period">300</property> <!--максимальное количество соединений в пуле--> <property name="hibernate.c3p0.max_size">20</property> <!--минимальный размер пула--> <property name="hibernate.c3p0.min_size">4</property> <!--таймаут для с3p0--> <property name="hibernate.c3p0.timeout">320</property> <property name="hibernate.c3p0.max_statements">3</property> 
  1. Please explain the last point.
  2. If there are many connections, many connections to the database are opened, which do not close at all, what's the problem?

Thank you in advance.

2 answers 2

  1. hibernate.c3p0.max_statements - the cache size of statements .. probably, we are talking about the prepared statements
  2. Do not close at all? I mean, never at all? In theory, after a timeout, some may close. On the other hand, you should not care. The main thing is that in your application you release the connections (returned to the pool).
  • connections are not released, apparently something in the settings is not as necessary. I want 1. By default, there are 2 connections to the database. The first user sends a request to the application, 1 connection is used. The second ... the application is looking, yeah .. the first one is busy, we are using the second one. The third user appears, both connections are busy, create 2 more and add to the pool ... etc. In the end, I get a bunch of connections to the database, which do not close on timeout. - Jenkamen
  • So maybe this is because the client code does not release connections (does not return to the pool), so the pool does not interrupt them, but thinks they are busy. - cy6erGn0m
  • No, not because of that. 100% in the c3p0 setup, only where ... - Jenkamen

hibernate.c3p0.max_statements - the size of the cache of states ... probably we are talking about the prepared statements

Tell me, what is meant by the statement here? I change the value between 20 and 5000 and I don’t see the difference (hangs once an hour). Everywhere they write that max_statements is the maximum number of statements, and how they are created, accumulated, cleared is not clear.