我有以下php代码来检索数据库表中的所有行。但是,一旦我在Java中检索行,它将返回一个小于元素总数的行。这是php代码:
$con = mysql_connect("localhost", "username", "password");
mysql_select_db("Database", $con);
$query = "SELECT * FROM Table";
$result = mysql_query($query);
$output = array();
while($row = mysql_fetch_array($result))
{
$output[]=$row;
}
print(json_encode($output));
mysql_close($con);
该表包含以下元素
id user_id
1 user1
2 user2
3 user3
4 user4
5 user5
6 user6
在下面的java代码中,我只回溯了5个元素,而不是6个。是否有一些我缺少的基本内容?
httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
String js;
String userName = null;
try {
InputStream responseData;
responseData = httpEntity.getContent();
js = convertStreamToString(responseData);
Log.v(LOG_TAG, js);
jArray = new JSONArray(js);
JSONObject json_data = null;
Log.v("CompareActivity", "js is " + js);
Log.v(LOG_TAG, "Arraysize: " + jArray.length());
... }