Search code examples
hibernatejdbcfirebirdjaybird

Firebird excessive logging


I'm using WildFly 10 with Hibernate and some JDBC. I have no logs at all If I declare my data source like this:

<datasource jta="true" jndi-name="java:jboss/Firebird" pool-name="FirebirdPool" enabled="true" spy="true" use-ccm="true" statistics-enabled="false">
<connection-url>jdbc:firebirdsql:localhost/3050:C:\banco\COMPLEXO140116.FDB</connection-url>

But if I declare passing:

?defaultResultSetHoldable=True&amp;encoding=WIN1252

it logs

09:54:00,384 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper (default task-3) SQL Warning Code: 0, SQLState: 01000

09:54:00,384 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-3) null

at every query


Solution

  • The logging is done by Hibernate, not by Firebird or Jaybird. The reason this happens is because you have specified defaultResultSetHoldable=True. This setting will make all statements have holdability HOLD_CURSORS_OVER_COMMIT. In Jaybird HOLD_CURSORS_OVER_COMMIT is implemented by using TYPE_SCROLL_INSENSITIVE, but the default is TYPE_FORWARD_ONLY, so Jaybird upgrades the result set type, and in compliance with the JDBC specification (section 15.1.1 of JDBC 4.2), this registers a warning which is then logged by Hibernate.

    If the driver does not support the type supplied to the methods createStatement, prepareStatement, or prepareCall, it generates an SQLWarning on the Connection object that is creating the statement.

    Unfortunately, a bug in the SQLWarning subclass used by Jaybird causes the message to be null instead of the actual message ("Holdable result set must be scrollable.").

    Your options are either not specifying defaultResultSetHoldable=True or configuring Hibernate to not log warnings using configuration property hibernate.jdbc.log.warnings=false.

    Out of curiosity: why are you specifying defaultResultSetHoldable=True? It is an option that can be bad for performance as it caches the entire result set in the driver, and it is primarily intended as a workaround for applications that try to access the result set after (auto) commit.