Enroute to figuring out my problem, I discover there is something I don't understand about how exceptions get handled. This exception boils up into my code in response to my call (in DataBase line 445) to java.sql.Statement.executeQuery(), which throws SQLException. But SocketException is not a descendant of SQLException. So I don't understand how I am finding a SocketException in a nest where I expect to see only SQLExceptions.
I think that the SocketException is just part of the "exception chain" that the SQLException is the ultimate manifestation of. That is, somewhere in the underlying code, a SocketException was caught, and then attached to an SQLException using setNextException() or initCause(). That SQLException is then thrown and is what you're seeing in your code.
Being an upright citizen, I want to do the right thing and catch this pesky SocketException, right where it pops up in my code. But the compiler insultingly says "Unreachable catch block".
If it's happening the way I think it is, you can't exactly catch the SocketException, because it's "wrapped" inside an SQLException. If
you want to handle the SocketException case differently than some
other underlying cause, you'd have to do something like below.
whether you would use getNextException() of getCause() would depend on whether the underlying code that throws the SQLException is using the old style chaining using setNextException(), or the newer style using initCause().
You may have to experiment a little to decide which it is.
catch( SQLException sqle )
{
Throwable t = sqle.getNextException();
// OR
Throwable t = sqle.getCause(): if( t instanceof SocketException )
{
// do something
}
else if( t instanceof Whatever )
{
// do something else
}}
HTH, IANAL, YMMV, Standard Disclaimers Apply, Etc...
TTYL,
Phil
--
When the 1st Amendment no longer protects your voice.
And when the 4th Amendment no longer protects your privacy or your stuff.
Thank God we have the 2nd Amendment to tell our elected representatives that enough is enough.
It's time to put "... from my cold, dead hands" back where it belongs.
FREE AMERICA Vote Libertarian www.lp.org
_______________________________________________ Juglist mailing list [EMAIL PROTECTED] http://trijug.org/mailman/listinfo/juglist_trijug.org
