As far as I understand the functionality of ExceptionSorter, it is used to determine, whether the exception is fatal or not (fatal means: the connection is broken and unusable). When a fatal exception occurs, then the connection is removed from the pool.
The problem is, that broken connections are destroyed one by one. If your pool contains 1000 connections, you need 1000 requests (that throw the fatal exception) to clean and re-establish the pool. It would be nice to be able to re-initialize all connections to the same data source when a single connection breaks down.
It seems that I was wrong. I made some more tests and the server re-established the pool without removing all connections one by one.
Is the ExceptionSorter supported in JBoss3.0.4? If not, how can I get the connection pool to refresh its pool of connections if the connections are stale/invalid?
I have implemented an ExceptionSorter for my AS400 connection.
The reconnect works, eventually, but only after it fails one time to recreate the connection.
In other words, when the connection is lost, I get an error when using the connection then after that it manages to reconnect again. Is this the normal behaviour?
Here is the configuration of my datasource
and here is the content of the isExceptionFatal method
public boolean isExceptionFatal(SQLException e)
boolean ret = false;
if(e != null && e.getSQLState() != null)
ret = (e.getSQLState().equals("08003") || e.getSQLState().equals("08S01") || e.getSQLState().equals("40003"));
getLogger().debug("Connection closed by AS400. SQLState=(" + e.getSQLState() + "). Forcing reconnect. Error recieved:\n" + e.getMessage());
So if I understand the posts in this thread correctly, the ExceptionSorter is only used to determine if a connection related exception should be classified as fatal or not and if it is then destroy the connection and create a new one. But this does not occur until the connection has been used by the "requester". The user will therefore see that an exception occured, which is not ideal.
This is fine but it still does not meet the requirements for a highly available system. In a highly available system, the user should not have any clue that an invalid connection was used in the first place, The connection pool should be responsible for "testing" the connection by doing an initial "ping" of the server and only if this ping was successful should the connection be handed off to the connection "requester". Of course, there would be a performance penalty involved for taking the extra server hit for the initial ping but this would be a tradeoff for providing transparent database failover. It doesn't seem like this would be hard to implement and is critical for any mission critical enterprise level application.
AFAIK the ExceptionSorter is not supported in JBoss 3.0.4.
I made some tests and it seems that 3.0.4 is able to refresh connections anyway. I stopped my database while the application server was running. JBoss started throwing exceptions (complaining that the database/network IO error occured). Then I re-started the database and after some time (a few minutes) my application connected to the database again. I tested this with JBoss 3.0.4 and JBoss 3.2.1, my database is MySQL.
It appears that you can make do without an ExceptionSorter. I must admit now that I don't completely understand what is the intended purpose of exception sorters. :-))
In the data-source configuration file, it is possible to define an SQL statement, that will test the validity of a connection before it is returned from the pool. Use the "check-valid-connection-sql" tag.
I am using Oracle 8.1.7 and jboss 3.0.4. I also ran some tests but the connections are not refreshed. I disconnected my LAN toggle from the network adapter card and tried connecting to the database through my application - an exception was thrown. After reconnecting the toggle to the network card and any subsequent attempts to reconnect to the database, cause an exception to be thrown (socket error). The connections returned from the pool are stale or invalid. In my opinion, it should be the job of the connection pool to check whether the connection it is returning is valid before returning a connection. The ExceptionSorter is supposed to handle these type of errors (i.e. socket error) and refresh the pool of connections - it's a shame it's not available in 3.0.4 because that's exactly what I need.
I forgot to mention, that my database and application server run on the same machine (Windows XP). In this case it might be easier to re-establish lost connections.
The <check-valid-connection-sql> tag I mentioned in my previous post is also not available in JBoss 3.0.4.