public boolean delete(String id) { boolean result = false; try { WasConfig pvo = (WasConfig) findByID(id + ""); String ipstr = pvo.getIpaddress(); String allipstr = SysUtil.doip(ipstr); CreateTableManager ctable = new CreateTableManager(); ctable.deleteTable("wasping", allipstr, "wasping"); // Ping ctable.deleteTable("waspinghour", allipstr, "waspinghour"); // Ping ctable.deleteTable("waspingday", allipstr, "waspingday"); // Ping // 自服务器启动以来的CPU平均使用率 ctable.deleteTable("wasrcpu", allipstr, "wasrcpu"); // Ping ctable.deleteTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping ctable.deleteTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping // 自上次查询以来的平均CPU使用率 ctable.deleteTable("wasscpu", allipstr, "wasscpu"); // Ping ctable.deleteTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping ctable.deleteTable("wasscpuday", allipstr, "wasscpuday"); // Ping // 缓存命中率 ctable.deleteTable("wasrate", allipstr, "wasrate"); // Ping ctable.deleteTable("wasratehour", allipstr, "wasratehour"); // Ping ctable.deleteTable("wasrateday", allipstr, "wasrateday"); // Ping // JVM内存利用率 ctable.deleteTable("wasjvm", allipstr, "wasjvm"); ctable.deleteTable("wasjvmhour", allipstr, "wasjvmhour"); ctable.deleteTable("wasjvmday", allipstr, "wasjvmday"); // 性能表 ctable.deleteTable("wassystem", allipstr, "wassystem"); ctable.deleteTable("wassystemhour", allipstr, "wassystemhour"); ctable.deleteTable("wassystemday", allipstr, "wassystemday"); ctable.deleteTable("wasjdbc", allipstr, "wasjdbc"); ctable.deleteTable("wasjdbchour", allipstr, "wasjdbchour"); ctable.deleteTable("wasjdbcday", allipstr, "wasjdbcday"); ctable.deleteTable("wassession", allipstr, "wassession"); ctable.deleteTable("wassessionh", allipstr, "wassessionh"); // wassessionhour // 必须保留session字段 ctable.deleteTable("wassessiond", allipstr, "wassessiond"); // wassessionday ctable.deleteTable("wasjvminfo", allipstr, "wasjvminfo"); ctable.deleteTable("wasjvminfoh", allipstr, "wasjvmhour"); // wasjvminfohour // 必须保留jvminfo字段 ctable.deleteTable("wasjvminfod", allipstr, "wasjvmday"); // wasjvminfoday ctable.deleteTable("wascache", allipstr, "wascache"); ctable.deleteTable("wascachehour", allipstr, "wascachehour"); ctable.deleteTable("wascacheday", allipstr, "wascacheday"); ctable.deleteTable("wasthread", allipstr, "wasthread"); ctable.deleteTable("wasthreadhour", allipstr, "wasthreadhour"); ctable.deleteTable("wasthreadday", allipstr, "wasthreadday"); ctable.deleteTable("wastrans", allipstr, "wastrans"); ctable.deleteTable("wastranshour", allipstr, "wastranshour"); ctable.deleteTable("wastransday", allipstr, "wastransday"); conn.addBatch("delete from nms_wasconfig where id=" + id); conn.executeBatch(); result = true; try { // 同时删除事件表里的相关数据 EventListDao eventdao = new EventListDao(); eventdao.delete(Integer.parseInt(id), "wasserver"); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { conn.close(); } return result; }
public boolean update(BaseVo vo) { boolean flag = true; WasConfig vo1 = (WasConfig) vo; WasConfig pvo = (WasConfig) findByID(vo1.getId() + ""); StringBuffer sql = new StringBuffer(); sql.append("update nms_wasconfig set name='"); sql.append(vo1.getName()); sql.append("',ipaddress='"); sql.append(vo1.getIpaddress()); sql.append("',portnum='"); sql.append(vo1.getPortnum()); sql.append("',nodename='"); sql.append(vo1.getNodename()); sql.append("',servername='"); sql.append(vo1.getServername()); sql.append("',sendmobiles='"); sql.append(vo1.getSendmobiles()); sql.append("',mon_flag='"); sql.append(vo1.getMon_flag()); sql.append("',netid='"); sql.append(vo1.getNetid()); sql.append("',sendemail='"); sql.append(vo1.getSendemail()); sql.append("',supperid='"); sql.append(vo1.getSupperid()); sql.append("',version='"); sql.append(vo1.getVersion()); sql.append("' where id=" + vo1.getId()); try { conn = new DBManager(); saveOrUpdate(sql.toString()); if (!vo1.getIpaddress().equals(pvo.getIpaddress())) { String ipstr = pvo.getIpaddress(); String allipstr = SysUtil.doip(ipstr); CreateTableManager ctable = new CreateTableManager(); // conn = new DBManager(); ctable.deleteTable("wasping", allipstr, "wasping"); // Ping ctable.deleteTable("waspinghour", allipstr, "waspinghour"); // Ping ctable.deleteTable("waspingday", allipstr, "waspingday"); // Ping // 自服务器启动以来的CPU平均使用率 ctable.deleteTable("wasrcpu", allipstr, "wasrcpu"); // Ping ctable.deleteTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping ctable.deleteTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping // 自上次查询以来的平均CPU使用率 ctable.deleteTable("wasscpu", allipstr, "wasscpu"); // Ping ctable.deleteTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping ctable.deleteTable("wasscpuday", allipstr, "wasscpuday"); // Ping // 缓存命中率 ctable.deleteTable("wasrate", allipstr, "wasrate"); // Ping ctable.deleteTable("wasratehour", allipstr, "wasratehour"); // Ping ctable.deleteTable("wasrateday", allipstr, "wasrateday"); // Ping // JVM内存利用率 ctable.deleteTable("wasjvm", allipstr, "wasjvm"); ctable.deleteTable("wasjvmhour", allipstr, "wasjvmhour"); ctable.deleteTable("wasjvmday", allipstr, "wasjvmday"); // 性能表 ctable.deleteTable("wassystem", allipstr, "wassystem"); ctable.deleteTable("wassystemhour", allipstr, "wassystemhour"); ctable.deleteTable("wassystemday", allipstr, "wassystemday"); ctable.deleteTable("wasjdbc", allipstr, "wasjdbc"); ctable.deleteTable("wasjdbchour", allipstr, "wasjdbchour"); ctable.deleteTable("wasjdbcday", allipstr, "wasjdbcday"); ctable.deleteTable("wassession", allipstr, "wassession"); ctable.deleteTable("wassessionh", allipstr, "wassessionh"); // wassessionhour // 必须保留session字段 ctable.deleteTable("wassessiond", allipstr, "wassessiond"); ctable.deleteTable("wasjvminfo", allipstr, "wasjvminfo"); ctable.deleteTable("wasjvminfoh", allipstr, "wasjvminfoh"); // wasjvminfohour // 必须保留jvminfo字段,详情见函数内部 ctable.deleteTable("wasjvminfod", allipstr, "wasjvminfod"); // wasjvminfoday ctable.deleteTable("wascache", allipstr, "wascache"); ctable.deleteTable("wascachehour", allipstr, "wascachehour"); ctable.deleteTable("wascacheday", allipstr, "wascacheday"); ctable.deleteTable("wasthread", allipstr, "wasthread"); ctable.deleteTable("wasthreadhour", allipstr, "wasthreadhour"); ctable.deleteTable("wasthreadday", allipstr, "wasthreadday"); ctable.deleteTable("wastrans", allipstr, "wastrans"); ctable.deleteTable("wastranshour", allipstr, "wastranshour"); ctable.deleteTable("wastransday", allipstr, "wastransday"); try { // 同时删除事件表里的相关数据 EventListDao eventdao = new EventListDao(); eventdao.delete(vo1.getId(), "wasserver"); } catch (Exception e) { e.printStackTrace(); } // 测试生成表 String ip = vo1.getIpaddress(); allipstr = SysUtil.doip(ip); ctable = new CreateTableManager(); // 可用性 ctable.createTable("wasping", allipstr, "wasping"); // Ping ctable.createTable("waspinghour", allipstr, "waspinghour"); // Ping ctable.createTable("waspingday", allipstr, "waspingday"); // Ping // 自服务器启动以来的CPU平均使用率 ctable.createTable("wasrcpu", allipstr, "wasrcpu"); // Ping ctable.createTable("wasrcpuhour", allipstr, "wasrcpuhour"); // Ping ctable.createTable("wasrcpuday", allipstr, "wasrcpuday"); // Ping // 自上次查询以来的平均CPU使用率 ctable.createTable("wasscpu", allipstr, "wasscpu"); // Ping ctable.createTable("wasscpuhour", allipstr, "wasscpuhour"); // Ping ctable.createTable("wasscpuday", allipstr, "wasscpuday"); // Ping // 缓存命中率 ctable.createTable("wasrate", allipstr, "wasrate"); // Ping ctable.createTable("wasratehour", allipstr, "wasratehour"); // Ping ctable.createTable("wasrateday", allipstr, "wasrateday"); // Ping // JVM内存利用率 ctable.createTable("wasjvm", allipstr, "wasjvm"); ctable.createTable("wasjvmhour", allipstr, "wasjvmhour"); ctable.createTable("wasjvmday", allipstr, "wasjvmday"); // 建立性能表 ctable.createWasTable(conn, "wassystem", allipstr); ctable.createWasTable(conn, "wassystemhour", allipstr); ctable.createWasTable(conn, "wassystemday", allipstr); ctable.createWasTable(conn, "wasjdbc", allipstr); ctable.createWasTable(conn, "wasjdbchour", allipstr); ctable.createWasTable(conn, "wasjdbcday", allipstr); ctable.createWasTable(conn, "wassession", allipstr); ctable.createWasTable(conn, "wassessionh", allipstr); // wassessionhour ctable.createWasTable(conn, "wassessiond", allipstr); ctable.createWasTable(conn, "wasjvminfo", allipstr); ctable.createWasTable(conn, "wasjvminfoh", allipstr); // wasjvminfohour ctable.createWasTable(conn, "wasjvminfod", allipstr); // wasjvminfoday ctable.createWasTable(conn, "wascache", allipstr); ctable.createWasTable(conn, "wascachehour", allipstr); ctable.createWasTable(conn, "wascacheday", allipstr); ctable.createWasTable(conn, "wasthread", allipstr); ctable.createWasTable(conn, "wasthreadhour", allipstr); ctable.createWasTable(conn, "wasthreadday", allipstr); ctable.createWasTable(conn, "wastrans", allipstr); ctable.createWasTable(conn, "wastranshour", allipstr); ctable.createWasTable(conn, "wastransday", allipstr); } } catch (Exception e) { flag = false; e.printStackTrace(); } finally { conn.close(); } return flag; }