How do I check if a Connection is still valid / has been closed?

John Zukowski

With JDBC 4.0, you can call the isValid(int timeout) method. The timeout represents the number of seconds to wait for a reply. If no reply is acquired during the time, false is returned and the caller is unblocked. A timeout value of 0 means to wait forever.