Clarification on DB connection testing in Java