【问题标题】:Get the count value in android app from webservice从 webservice 获取 android 应用中的计数值
【发布时间】:2012-08-01 13:08:38
【问题描述】:

如果我运行我的应用程序,计数值会显示在我的 tomcat-apache 上,但不会显示在我的 Android 模拟器上。为什么这里会出现这个错误?我应该在哪里更改我的代码: dis 是我的网络服务代码:

       PreparedStatement statement =  con.prepareStatement("select * from orders where status='Q' AND date = CURDATE()");

        ResultSet result = statement.executeQuery();

       while(result.next()){

   int count=0;
   count++;
  System.out.println(count);
   }
   }

   catch(Exception exc){
     System.out.println(exc.getMessage());
      }

    return customerInfo;
    }

这是我的安卓代码:

       HttpTransportSE ht = new HttpTransportSE(URL);
        try {
        ht.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        SoapPrimitive s = response;
        String str = s.toString();
        String resultArr[] = str.split("&");//Result string will split & store in an array

        TextView tv = new TextView(this);

        for(int i = 0; i<resultArr.length;i++){
        tv.append(resultArr[i]+"\n\n");
       }
        setContentView(tv);

    } catch (Exception e) {
        e.printStackTrace();
    }

【问题讨论】:

    标签: java android mysql web-services soap


    【解决方案1】:

    您需要在循环之外声明计数(以及打印语句):

    int count=0;    
    while(result.next()){
       count++;
    }
    System.out.println(count);
    

    【讨论】:

    • 现在计数值也只显示在我的 apache 控制台窗口上..不显示在我的 android 模拟器上
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多