jdbc 有点搞不懂状况了,记录下来

    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时,循环里只执行一次。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值