0

i have created web application using java. In that i am using tomcat server and SQL server. I need to implement watch dog service for monitoring database connection and server connection. I mean if database is not connecting or tomcat server is down then i need to write a code for send a alerting mail to my mail id.

pls someone help me...

4

1 回答 1

0

您可以创建一个单独的线程来监控数据库连接。在启动服务器时调用该线程。如果数据库连接失败意味着发送来自该威胁的邮件。

例子 :

        boolean isDBConnected,isServerConnected;
        while(true){                
            isDBConnected=checkDBConnection();
            isServerConnected=checkServerStatus();
            if(isDBConnected && isServerConnected){
                Thread.sleep(100);
            }else{
                sendMail();
                break;
            }
        }
于 2012-11-07T09:16:57.300 回答