Connection validation in JBoss AS 7

Another problem with JDBC backend are broken connections. Most JDBC drivers can simply auto reconnect to server if connection is broken (for example database server is restarted). But postgres sql does not. Luckily JBOSS provides some iteresting methods of connection validation. Its enough to add connection checker and exception sorter classes.

 


<connection-url>jdbc:postgresql://127.0.0.1/filezco</connection-url>

<driver-class>org.postgresql.Driver</driver-class>

<driver>postgresql-8.4-703.jdbc3.jar</driver>

<validation>

<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>

<validate-on-match>false</validate-on-match>

<background-validation>false</background-validation>

<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>

</validation>