catch (Exception e)
{
System.err.println ("Cannot connect to database server");
}

It is always best practice to gather information from the exception -...