Version 3

    I get an SQLException with an IO or Network Error


    This means the connection to the database has broken.


    New Connections


    JBoss can detect this problem when the connection is being checked out from the pool.


    If JBoss detects the connection is broken before it is checked out from the pool, the application does

    not see the problem. A warning is logged and JBoss chooses a different connection. It will create new connections if necessary.


    In use Connections


    However, if the connection has already been checked out from the pool and breaks while the application is using the connection, there is nothing JBoss can do about it.


    There is state associated with the connection inside the database that JBoss cannot recover.


    The only recovery possible is to propagate the exception back to the application and let it rollback the transaction. Once the transaction is rolled back, the application can retry the unit of work.




    SQLException is an application exception according to the EJB spec. That means it does not automatically rollback the transaction. The application must do something like the following to force a rollback:

       // do work
    catch (SQLException e)
       throw new ApplicationException(e);


    or throw a RuntimeException like EJBException.


    Exception Sorter


    JBoss has an interface called ExceptionSorter

    that can be coded to look at vendor specific error codes to decide whether an SQLException is a fatal exception that requires the connection to be closed.

    Vendor specific implementations are provided for some databases.


    It is configured on the datasource:

        <!-- HERE -->
        <!-- Checks the Oracle error codes and messages for fatal errors -->
          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->




    JBoss JCA Main Page