I've setup a MySql server using xampp, I am creating an android app to connect to the database. I can connect without a problem using MYSQL Workbench and ODBC connector from off site and ably to push/pull data without errors. when connecting with the EMULATED phone I am getting "org.apache.http.conn.httphostconnectexception connection to http://x.x.x.x:88/mobile.php refused" in the DDMS. Any idea why this is happening???
Allow Internet wasn't turned on... it is now , just verified, cleaned and relaunched, now I am getting "ClientProtocolException".
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());
}
}