正在将“org.apache.http.conn.httphostconnectexception”连接获取到http://x.x.x.x:88/mobile.php 拒绝
我已经使用xampp设置了一个MySql服务器,我正在创建一个android应用程序来连接数据库。我可以使用MySql Workbench和ODBC connector在场外毫无问题地连接,并且能够无错误地推/拉数据。当连接到模拟手机时,我得到org.apache.http.conn.httphostconnectexception连接到ref在DDMS中使用。知道为什么会发生这种情况吗 允许互联网没有打开…现在,只是验证、清理和重新启动,现在我得到了ClientProtocolException正在将“org.apache.http.conn.httphostconnectexception”连接获取到http://x.x.x.x:88/mobile.php 拒绝,php,android,mysql,Php,Android,Mysql,我已经使用xampp设置了一个MySql服务器,我正在创建一个android应用程序来连接数据库。我可以使用MySql Workbench和ODBC connector在场外毫无问题地连接,并且能够无错误地推/拉数据。当连接到模拟手机时,我得到org.apache.http.conn.httphostconnectexception连接到ref在DDMS中使用。知道为什么会发生这种情况吗 允许互联网没有打开…现在,只是验证、清理和重新启动,现在我得到了ClientProtocolExceptio
public void getData() {
String result = "";
InputStream isr = null;
try {
HttpClient httpclient = new DefaultHttpClient();
///external ip address not local host or trying inside a local network
HttpPost httpost = new HttpPost("http://x.x.x.x:88/mobile.php");
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
isr = entity.getContent();
} catch (Exception e) {
Log.e("log.tag", "Error in http connection " + e.toString());
resultView.setText("Could not connect to Database");
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
isr, "iso=8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
isr.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log.tag", "Error converting result " + e.toString());
}
try {
String s = "";
JSONArray jArray = new JSONArray(result);
for (int i = 0; i < jArray.length(); i++) {
JSONObject json = jArray.getJSONObject(i);
s = s + "User :" + json.getString("UserName");
}
resultView.setText(s);
} catch (Exception e) {
Log.e("log.tag", "Error Parsing Data " + e.toString());
}
}
实现此功能的步骤: 将INTERNET权限添加到您的清单中 确保没有防火墙或代理从服务器端阻止 在httpPost声明之后添加httpPost.setHeaderAccept,application/json
你确定你的清单中有INTERNET权限吗?请确保服务器防火墙没有被阻止。或者可能是防病毒。服务器防火墙或路由器正在被阻止,可以通过ODBC和MYSQL Workbench,INTERNET权限没有被添加,现在是。现在我正在获取ClientProtocolException。请尝试使用httpPost.SetHeaderAccesspt,application/json;在HttpPost-httpost=new-HttpP行之后osthttp://x.x.x.x:88/mobile.php;