The Javadoc is clear enough.
isClose()
is only guaranteed to return true if the connection was closed by a call to Connection.close()
. If the connection was closed due to some errors, isClose()
will not necessarily return true. Therefore, if it returns true, you can be sure the connection is closed, but if it returns false, you can't be sure.
isValid()
does the opposite of isClose()
. It attempts to do a positive check that the connection is still open, by running a database query. If it returns true
, you know for sure the connection is open. If it returns false, you can't be sure if it's open or not (since the query may be delayed due to some network issues, which prevent it from completing before the given timeout).