Is there a specific method in Java that checks whether a MySQL server is alive?
It depends on what method you use to connect to the database. Some drivers, eg MySQL Connector/J do have a ping command:
/**
* Detect if the connection is still good by sending a ping command
* to the server.
*
* @throws SQLException
* if the ping fails
*/
public abstract void ping() throws SQLException;
If you an interface that does not support this then a simple method that always works is to connect to the database as you ordinarily would and execute the following query:
SELECT 1
You should get back a result set containing a single row, with a single column, containg the value 1. If this succeeds your MySQL is working.