Para verificar se o Network Server do Derby está executando no momento, é utilizado o comando ping.
O comando ping pode ser utilizado das seguintes maneiras:
private static boolean isServerStarted(NetworkServerControl server, int ntries)
{
for (int i = 1; i <= ntries; i ++)
{
try {
Thread.sleep(500);
server.ping();
return true;
}
catch (Exception e) {
if (i == ntries)
return false;
}
}
return false;
}