2016-02-26 52 views
0

首先原諒的英語不好。我對android應用程序開發頗爲陌生。所以幾個星期,我嘗試通過教程學習。 This one particular tutorial是在我的「我真的需要了解這一個」名單。所以我嘗試使用免費託管遠程服務器的教程,byethost。我想使用像wamp這樣的本地服務器,但是目前我的個人筆記本電腦壞了,所以我不得不使用我的辦公室筆記本電腦。無法從Android的增值遠程服務器

問題IM面是,我不能增加價值的服務器。我只更改了Config.java中的一些代碼,並使用dbConnect.php來連接我的服務器。

dbConnect.php

<?php 
/* 
    author: Belal Khan 
    website: https://www.simplifiedcoding.net 

    My Database is androiddb 
    you need to change the database name rest the things are default if you are using wamp or xampp server 
    You may need to change the host user name or password if you have changed the defaults in your server 
*/ 

//Defining Constants 
define('HOST','sql106.byethost6.com '); 
define('USER','#######'); 
define('PASS','#######'); 
define('DB','######'); 

//Connecting to Database 
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect'); 

Config.Java

public class Config { 

//Address of our scripts of the CRUD 
public static final String URL_ADD="https://benerin.byethost6.com/simpcoding/crud/addEmp.php"; 
public static final String URL_GET_ALL = "https://benerin.byethost6.com/simpcoding/crud/getAllEmp.php"; 
public static final String URL_GET_EMP = "https://benerin.byethost6.com/simpcoding/crud/getEmp.php?id="; 
public static final String URL_UPDATE_EMP = "https://benerin.byethost6.com/simpcoding/crud/updateEmp.php"; 
public static final String URL_DELETE_EMP = "https://benerin.byethost6.com/simpcoding/crud/deleteEmp.php?id="; 

//Keys that will be used to send the request to php scripts 
public static final String KEY_EMP_ID = "id"; 
public static final String KEY_EMP_NAME = "name"; 
public static final String KEY_EMP_DESG = "desg"; 
public static final String KEY_EMP_SAL = "salary"; 

//JSON Tags 
public static final String TAG_JSON_ARRAY="result"; 
public static final String TAG_ID = "id"; 
public static final String TAG_NAME = "name"; 
public static final String TAG_DESG = "desg"; 
public static final String TAG_SAL = "salary"; 

//employee id to pass with intent 
public static final String EMP_ID = "emp_id";} 

在我的logcat它按添加員工按鈕

02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:306) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.Connection.upgradeToTls(Connection.java:201) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.Connection.connect(Connection.java:155) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:208) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.RequestHandler.sendPostRequest(RequestHandler.java:49) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.MainActivity$1AddEmployee.doInBackground(MainActivity.java:78) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.MainActivity$1AddEmployee.doInBackground(MainActivity.java:53) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.AsyncTask$2.call(AsyncTask.java:288) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at java.lang.Thread.run(Thread.java:818) 
02-26 11:26:14.751 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:318) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:219) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:113) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:525) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302) 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  ... 18 more 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 
02-26 11:26:14.761 19909-19945/net.simplifiedcoding.mysqlcrud W/System.err:  ... 24 more 

,並顯示這個時候顯示了這個錯誤WH恩按下查看員工

02-26 11:28:11.301 19909-19909/net.simplifiedcoding.mysqlcrud V/Monotype: SetAppTypeFace- try to flip, app = net.simplifiedcoding.mysqlcrud 
02-26 11:28:11.301 19909-19909/net.simplifiedcoding.mysqlcrud V/Monotype:  Typeface getFontPathFlipFont - systemFont = default#default 
02-26 11:28:11.531 19909-19940/net.simplifiedcoding.mysqlcrud D/OpenGLRenderer: endAllStagingAnimators on 0xb82454c0 (RippleDrawable) with handle 0xb81adca0 
02-26 11:28:16.281 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err: org.json.JSONException: End of input at character 0 of 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at org.json.JSONTokener.syntaxError(JSONTokener.java:450) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at org.json.JSONTokener.nextValue(JSONTokener.java:97) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at org.json.JSONObject.<init>(JSONObject.java:156) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at org.json.JSONObject.<init>(JSONObject.java:173) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.ViewAllEmployee.showEmployee(ViewAllEmployee.java:44) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.ViewAllEmployee.access$100(ViewAllEmployee.java:24) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.ViewAllEmployee$1GetJSON.onPostExecute(ViewAllEmployee.java:85) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at net.simplifiedcoding.mysqlcrud.ViewAllEmployee$1GetJSON.onPostExecute(ViewAllEmployee.java:71) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.AsyncTask.finish(AsyncTask.java:632) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.AsyncTask.access$600(AsyncTask.java:177) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.Handler.dispatchMessage(Handler.java:102) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.os.Looper.loop(Looper.java:135) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at android.app.ActivityThread.main(ActivityThread.java:5253) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at java.lang.reflect.Method.invoke(Native Method) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at java.lang.reflect.Method.invoke(Method.java:372) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 
02-26 11:28:16.291 19909-19909/net.simplifiedcoding.mysqlcrud W/System.err:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 

誰能告訴我什麼是錯的呢?如果我在我的學習中跳得太遠,那麼理解這一點最好的開始是什麼?

回答