Hi Derby Users,

We need to detect a connection lost between Derby (in server mode) and our 
swing client.
Our goal is to provide a more user friendly message (with ping button, a 
troubleshooting procedure and more).

Right now, we use the below pattern to detect some connection lost, but some of 
them were not catched because we use an ORM framework who catches them :
=============
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() 
{
            @Override
            public void uncaughtException(Thread thread, Throwable thrwbl) {
                for (Throwable cause = thrwbl.getCause(); cause != null; cause 
= cause.getCause()) {
                    if (cause instanceof DisconnectException) {
                        fireDisconnected();
                        break;
                    }
                }
            }
        });
========

IMO, an interesting feature will be a listener pattern provided by the JDBC 
driver. In this way, if a DisconnectedException will be throws, we will can 
notify a connection lost to another observers.

Regards,
Guillaume

Reply via email to