Search in sources :

Example 1 with MachineInfo

use of beans.dbaccess.MachineInfo in project MSEC by Tencent.

the class QueryMachineList method exec.

public QueryMachineListResponse exec(QueryMachineListRequest request) {
    QueryMachineListResponse resp = new QueryMachineListResponse();
    String result = checkIdentity();
    if (!result.equals("success")) {
        resp.setStatus(99);
        resp.setMessage(result);
        return resp;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        resp.setStatus(100);
        resp.setMessage("db connect failed!");
        return resp;
    }
    List<MachineInfo> machineInfoList;
    //System.out.printf("name:%s, ip:%s\n", request.getMachine_name(), request.getMachine_ip());
    String sql = "select machine_name, machine_ip, os_version, gcc_version, java_version from t_machine ";
    List<Object> params = new ArrayList<Object>();
    if (request.getMachine_name() != null && request.getMachine_name().length() > 0) {
        sql += " where machine_name=? ";
        params.add(request.getMachine_name());
    } else if (request.getMachine_ip() != null && request.getMachine_ip().length() > 0) {
        sql += " where machine_ip=? ";
        params.add(request.getMachine_ip());
    }
    try {
        machineInfoList = util.findMoreRefResult(sql, params, MachineInfo.class);
    } catch (Exception e) {
        resp.setStatus(100);
        resp.setMessage("db query exception!");
        e.printStackTrace();
        return resp;
    } finally {
        util.releaseConn();
    }
    resp.setMachine_list((ArrayList<MachineInfo>) machineInfoList);
    resp.setMessage("success");
    resp.setStatus(0);
    return resp;
}
Also used : MachineInfo(beans.dbaccess.MachineInfo) DBUtil(ngse.org.DBUtil) QueryMachineListResponse(beans.response.QueryMachineListResponse) ArrayList(java.util.ArrayList)

Aggregations

MachineInfo (beans.dbaccess.MachineInfo)1 QueryMachineListResponse (beans.response.QueryMachineListResponse)1 ArrayList (java.util.ArrayList)1 DBUtil (ngse.org.DBUtil)1