package com.nms.server.thread;

import org.apache.log4j.Logger;

import com.nms.server.common.Common;
import com.nms.server.dao.CommonDao;

/**
 *	定时检查数据库连接是否可用
 *  @date May 7, 2013 2:31:50 PM
 *	@author ZhangGang
 *
 */
public class DBTestThread implements Runnable{
	private Logger logger = Logger.getLogger(DBTestThread.class);
	
	@Override
	public void run() {
//		Thread.currentThread().setName("数据库连接监听线程");
		Thread.currentThread().setName("Database Connection Listening Thread");
		CommonDao dao = null;
		try {
			dao = new CommonDao();
			Common.setDbConnectedFlag(true);
		} catch (Exception e) {
			/* 告警 */
			Common.setDbConnectedFlag(false);
			logger.error("Try to get a database connection failure", e);
		}finally{
			if(dao!=null){
				dao.close();
				dao=null;
			}
		}
	}
	
/*	public static void main (String []  args) {
		new Thread(new DBTestThread()).start();
	}*/
}
