Problem with Firebird Hibernate bank connection

Asked

Viewed 307 times

0

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 recover information in the base Firebird that she responds very well... But sometimes Firebird crashes or simply gets restarted, and then my application stayed It was jammed with communication problems even when the Firebird bank was back up and running. Then it was necessary to restart my application to get back to normal.

I solved this connection problem by adding the following commands 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...

Then I came across another problem.

Once the application is back up and running, it becomes unstable. It goes on to return synchronized connection errors according to the number of requests: time every three requests successfully one is returned the error (Always in that order); and if you do a new test, restarting the application, this schedule can change, as every 5 request a failure...

That mistake synchronized seems to me a symptom of a mistake that disarmed me...

All my configuration code from Hibernate.cfg.xml

<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 for the help of someone to try to solve this problem.

Unfortunately I could not find a solution, I believe it may be an error in the Firebird connection driver. But I managed to circumvent by creating a Windows service that tests the application from time to time and restarts apache Tomcat if there are any errors.

1 answer

0

According to the Hibernate documentation is highly discouraging use the property below, which was used in until version 2.x. I would take it out to do some tests.

<property name="hibernate.connection.release_mode">on_close</property>

Another property that seems to me not suitable is Hibernate.connection.Isolation. It is better to leave the standard used by the database. If you add it you have to know exactly what the past value means what you really want to change. In your case, you are using TRANSACTION_READ_UNCOMMITTED, That’s exactly what you want?

<property name="hibernate.connection.isolation">1</property>

One comment: The following property is false by default, you do not need to add it unless you want to pass the value to true:

<property name="hibernate.connection.autocommit">false</property>
  • thanks for the help @ramarcio. The isolation is the same that I need... because it is an application for online stock control, so I need to know the changes of a third transaction even before it is committed...I will do the test taking off release_mode.

  • @ramarcio, still continued with the problem after the changes, error that only happens after stopping and then starting the database.

  • 1

    That sucks, I don’t know what else it could be. Did you try testing with another database, like Mysql or any other? Sometimes it may be a bug from the database or the connection driver.

  • I’m going to test yes....

Browser other questions tagged

You are not signed in. Login or sign up in order to post.