-1

如果我运行我的应用程序,计数值会显示在我的 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();
    }
4

1 回答 1

0

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

int count=0;    
while(result.next()){
   count++;
}
System.out.println(count);
于 2012-08-01T13:13:02.950 回答