连接mysql数据库在Android失败 [英] Connection to database mySQL failed from android

查看:163
本文介绍了连接mysql数据库在Android失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在Android项目,当我试图使用PHP文件和的EasyPHP / MySQL的,它无法登录该应用程序,这里的logcat的错误:

am working on an android project, when i tried to login the application using a php file and easyphp/mySQL, it fails, here's the logcat errors:

    08-03 04:53:20.203: W/System.err(244): org.apache.http.NoHttpResponseException: The     target server failed to respond
    08-03 04:53:20.237: W/System.err(244):  at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:85)
    08-03 04:53:20.247: W/System.err(244):  at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:174)
    08-03 04:53:20.247: W/System.err(244):  at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:179)
    08-03 04:53:20.247: W/System.err(244):  at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:235)
    08-03 04:53:20.260: W/System.err(244):  at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:259)
    08-03 04:53:20.260: W/System.err(244):  at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:279)
    08-03 04:53:20.260: W/System.err(244):  at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
    08-03 04:53:20.282: W/System.err(244):  at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:410)
    08-03 04:53:20.288: W/System.err(244):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
    08-03 04:53:20.300: W/System.err(244):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
    08-03 04:53:20.307: W/System.err(244):  at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
    08-03 04:53:20.320: W/System.err(244):  at com.stage.sondage.Login.onClick(Login.java:109)
    08-03 04:53:20.320: W/System.err(244):  at android.view.View.performClick(View.java:2364)
    08-03 04:53:20.339: W/System.err(244):  at android.view.View.onTouchEvent(View.java:4179)
    08-03 04:53:20.358: W/System.err(244):  at android.widget.TextView.onTouchEvent(TextView.java:6540)
    08-03 04:53:20.358: W/System.err(244):  at android.view.View.dispatchTouchEvent(View.java:3709)
    08-03 04:53:20.367: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.379: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.387: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.401: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.401: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.401: W/System.err(244):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
    08-03 04:53:20.407: W/System.err(244):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
    08-03 04:53:20.420: W/System.err(244):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
    08-03 04:53:20.420: W/System.err(244):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
    08-03 04:53:20.420: W/System.err(244):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
    08-03 04:53:20.420: W/System.err(244):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
    08-03 04:53:20.427: W/System.err(244):  at android.os.Handler.dispatchMessage(Handler.java:99)
    08-03 04:53:20.438: W/System.err(244):  at android.os.Looper.loop(Looper.java:123)
    08-03 04:53:20.459: W/System.err(244):  at android.app.ActivityThread.main(ActivityThread.java:4363)
    08-03 04:53:20.459: W/System.err(244):  at java.lang.reflect.Method.invokeNative(Native Method)
    08-03 04:53:20.459: W/System.err(244):  at java.lang.reflect.Method.invoke(Method.java:521)
    08-03 04:53:20.459: W/System.err(244):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    08-03 04:53:20.467: W/System.err(244):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    08-03 04:53:20.517: W/System.err(244):  at dalvik.system.NativeStart.main(Native Method)

在登录该行109 =响应hhtpclient.execute(httppost);

,其中反应是Htt的presponse的实例;我试图与这两个值

where response is an instance of HttpResponse; and i have tried with both values

httppost=new HttpPost("http://10.0.2.2/android/connection.php"); 

httppost=new HttpPost("http://127.0.1.1/android/connection.php"); 

(由什么是两个IP不会忽略的区别的方式吗?)

( by the way what's the difference between the two ip adresses?)

感谢,

推荐答案

互联网在你的清单文件的权限是必需的。

The permission of internet in your manifest file is required.

<uses-permission android:name="android.permission.INTERNET"/> 

粘贴在申请后的标记清单文件。

paste this in your manifest file after application tag.

这篇关于连接mysql数据库在Android失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆