Connection conn = null;
Statement stm = null;
Statement stm1 = null;
ResultSet rs = null;
try {
Class.forName(drv).newInstance();
conn = DriverManager.getConnection(url, user, pwd);
stm = conn.createStatement();
stm1 = conn.createStatement();
String sqlSXJOn = "select distinct f_vc_fuwqip from B_JCSJ_LIUMTFWQJBXXB";
// 取出所有在线的流名称
GetAllXML getxml = new GetAllXML();
rs = stm.executeQuery(sqlSXJOn);
// while (rs.next()) {
// String lmtURL = "http://" + rs.getString("F_VC_FUWQIP")
// + ":1234/mctl?dev=live&act=get&type=push";
// System.out.println("checkSXJ lmtURL= " + lmtURL);
// }
while (rs.next()) {
String lmtURL = "http://" + rs.getString("F_VC_FUWQIP")
+ ":1234/mctl?dev=live&act=get&type=push";
// System.out.println("checkSXJ lmtURL= " + lmtURL);
Vector lmt = new Vector();
lmt.add(lmtURL);
String zxlmc = "''"; // 流名称
String[] lmtArr = lmtURL.split(":");
String lmtsIP = lmtArr[1].substring(2);
// System.out.println("lmtIP = " + lmtsIP + " lmtSize() = "
// + lmtIp.size());
Vector zx = null;
try {
zx = getxml.readerPageByUrl(lmt);
} catch (ConnectException e) {
}
// System.out.println("zxlmc 1= " + zx);
// zxlmc = zxlmc.substring(1, zxlmc.length() - 1);
if (zx != null) {
for (int j = 0; j < zx.size(); j++) {
if (zxlmc != "''") {
zxlmc = zxlmc + ", '" + zx.get(j) + "'";
} else {
zxlmc = "'" + zx.get(j) + "'";
}
}
}
// System.out.println("zxlmc = " + zxlmc);
String YXYSql = "update USR_JCSJ.B_JCSJ_YANXJKSBJBXX a set F_VC_SHEBZT='1' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_yanxsbwybs= b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%' and F_VC_FABM in (" + zxlmc + "))";
String YXNSql = "update USR_JCSJ.B_JCSJ_YANXJKSBJBXX a set F_VC_SHEBZT='0' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_yanxsbwybs= b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%' and F_VC_FABM not in (" + zxlmc + "))";
String FYYSql = "update USR_JCSJ.B_JCSJ_FEIYXSBJBXX a set F_VC_SHEBZT='1' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_feiyxsbwybs = b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%' and F_VC_FABM in (" + zxlmc + "))";
String FYNSql = "update USR_JCSJ.B_JCSJ_FEIYXSBJBXX a set F_VC_SHEBZT='0' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_fe"
+ ""
+ "iyxsbwybs = b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%' and F_VC_FABM not in (" + zxlmc + "))";
String bmqYSql = "update B_JCSJ_BIANMAQ set F_NB_ZT='1' where F_VC_URL like '%/"
+ lmtsIP + ":%' and f_vc_fabm in (" + zxlmc + ")";
String bmqNSql = "update B_JCSJ_BIANMAQ set F_NB_ZT='0' where F_VC_URL like '%/"
+ lmtsIP + ":%' and f_vc_fabm not in (" + zxlmc + ")";
String bmqNullSql = "update B_JCSJ_BIANMAQ set F_NB_ZT='0' where F_VC_URL like '%/"
+ lmtsIP + ":%'";
String FYNullSql = "update USR_JCSJ.B_JCSJ_FEIYXSBJBXX a set "
+ "F_VC_SHEBZT='0' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_feiyxsbwybs = b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%')";
String YXNullSql = "update USR_JCSJ.B_JCSJ_YANXJKSBJBXX a set F_VC_SHEBZT='0' "
+ " where exists (select f_vc_yanxsbwybs from B_JCSJ_BIANMAQ b "
+ " where a.f_vc_yanxsbwybs= b.f_vc_yanxsbwybs and F_VC_URL like '%/"
+ lmtsIP + ":%')";
// System.out.println("TestCheck YXYSql= " + YXYSql);
// System.out.println("TestCheck YXNSql= " + YXNSql);
//
// System.out.println("TestCheck FYYSql= " + FYYSql);
// System.out.println("TestCheck FYNSql= " + FYNSql);
//
// System.out.println("TestCheck bmqYSql= " + bmqYSql);
// System.out.println("TestCheck bmqNSql= " + bmqNSql);
if (zxlmc.trim().equals("''")) { // 没有ping通流媒体或者流媒体上没有摄像机
stm1.executeQuery(bmqNullSql);
stm1.executeQuery(FYNullSql);
stm1.executeQuery(YXNullSql);
// System.out.println("TestCheck 1bmqNullSql= " +
// bmqNullSql);
// System.out.println("TestCheck 2FYNullSql= " + FYNullSql);
// System.out.println("TestCheck 3YXNullSql= " + YXNullSql);
} else {
stm1.executeQuery(YXYSql);
stm1.executeQuery(FYYSql);
stm1.executeQuery(YXNSql);
stm1.executeQuery(FYNSql);
// 编码器是否在线修改
stm1.executeQuery(bmqYSql);
stm1.executeQuery(bmqNSql);
}
// System.out.println("modify 1!");
}
} catch (SQLException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
try {
stm.close();
stm1.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
当stm1修改为stm时,循环里只执行一次。