?? tailtools.java
字號:
package com.hoten.tail;
import java.sql.*;
import java.util.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class TailTools {
private static int flag = 0;
private static Hashtable list = new Hashtable(10);
public synchronized static void dealTail(String program,String ptype,String mtype,String msgdata) {
if(program==null||ptype==null||mtype==null||msgdata==null){
com.hoten.util.Log.printEvent("Program:" + program + " pType:" + ptype +
" mType:" + mtype + " Msg:" + msgdata,
com.hoten.util.MOParam.getInstance().
logFile);
return;
}
if (flag == 1) {
int size = list.size();
Enumeration keys = list.keys();
while(keys.hasMoreElements()){
String ip = (String)keys.nextElement();
String port = (String)list.get(ip);
int pt=0;
try {
pt = Integer.parseInt(port);
}
catch (Exception ex) {
continue;
}
TailInfo tailInfo = new TailInfo();
tailInfo.setStartFlag("@@@@");
tailInfo.setHost(ip);
tailInfo.setPort(pt);
tailInfo.setProgram(program);
tailInfo.setPType(ptype);
tailInfo.setMType(mtype);
tailInfo.setMsg(msgdata);
tailInfo.setEndFlag("####");
TailList.getInstance().add(tailInfo);
}
}
}
public synchronized static void setTailFlag(com.hoten.util.DBAccess dba){
String sql = "select ip,port from ddtservice where flag='2'";
Connection cn = null;
Statement stmt = null;
ResultSet rs = null;
boolean check = false;
try{
cn = dba.getConnection();
stmt = cn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
String ip = rs.getString(1);
String port = rs.getString(2);
if (ip != null && port != null) {
if (!check) {
list.clear();
check = true;
}
list.put(ip, port);
}
}
}catch(Exception ex){
check=false;
}
finally{
sql = null;
try{
rs.close();
stmt.close();
}catch(Exception ex){
}
dba.freeConnection(cn);
}
if(check&&flag==0) flag=1;
if(!check&&flag==1) flag=0;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -