I have an application in java that provides rest services with servlets and hibernate, which at first works perfectly. I can make thousands of requests to various services that retrieve information in firebird base that it responds very well ... But sometimes the firebird crashes or it simply reboots, and then my application would crash with communication problems even when the firebird bank was back up and running. So it was necessary to restart my application to go back to normal.
I solved this problem of re-connection by adding the commands below in the file hibernate.cfg.xml:
<property name="hibernate.c3p0.acquire_increment">5</property>
<property name="hibernate.c3p0.idle_test_period">120</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
After 120 seconds that the stopped flock returned to work, the application also restarted the connection, and allowed to make new requests ...
So I came across another problem.
Once the application is up and running, it becomes unstable. It then returns synchronized connection errors according to the number of requests: time for every three requests successfully one is returned the error (Always in that order); and if you do a new test, restarting the application, this timeline can change, as every 5 request a failure ...
This Synced error seems to me a symptom of an error that disarmed me ...
All my hibernate.cfg.xml configuration code
<property name="hibernate.dialect">org.hibernate.dialect.FirebirdDialect</property>
<property name="hibernate.connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="hibernate.connection.url">jdbc:firebirdsql://localhost:3050/D:/automacao/projetos/DB/DB.FDB</property>
<property name="hibernate.connection.username">USER</property>
<property name="hibernate.connection.password">*******</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.isolation">1</property>
<!--Configurações adicionais -->
<property name="current_session_context_class">thread</property>
<property name="connection.relaxAutoCommit">true</property>
<property name="connection.autoReconnect">true</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.release_mode">on_close</property>
<!-- Usando as configurações do C3PO para pool de conexões -->
<property name="hibernate.c3p0.acquire_increment">5</property>
<property name="hibernate.c3p0.idle_test_period">120</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
I ask someone to help me to solve this problem.
Unfortunately I could not find a solution, I think it might be a bug in the firebird connection driver. But I managed to get around creating a Windows service that tests the application from time to time and restarts apache tomcat if there is an error.