Edit
I have created Task which contains method which loads the content. I need task, because I want to set progress bar into undetermined state during data loading. When data is loaded, progress bar is set to "1" (completed).
What i want to achieve is: user logs in, but there is no connection so progress bar indicates that application is trying to connect and after a while and error message will pop-up and do this whenever connection is lost user tries to do something. But again, nothing is happening, this time no exception thrown.
It all freezes at conn = DriverManager.getConnection(DB_URL, USER, PASS), isValid() is not helping. End of Edit
Short version:
When connection with DB is lost, application hangs up and no exception is thrown, so i have nothing to catch and inform user about problem
Long version:
I am trying to simulate a "connection lost" situation in my application. What I want to achieve is to display "Connection to database has been lost" Dialog windows to infrom user about problem. This exception is called SQLNonTransientConnectionException. My problem is, I only receive it during login process. I have login windows, and if there is no connection, an exception is thrown.
But what if user lost connection after login? Like he is successfully logged in and during inserting/updating some table the connection is lost? In this case application just hangs up, it is not responding and no exception is thrown, so i have nothing to catch and infrom user about problem.
Could please help me how to achieve this?