我的inputstream在mysql上建立了一个post请求保存后,返回java.io.filenotfoundexception和我的网址。我曾经成功地写了一次mysql服务器,但它只是停止工作。我正在尝试将数据插入我服务器上的mysql。用于打开连接和插入的php文件都是正确的,但是在后台异步操作会返回ioexception。
这是我的密码
String users_url = "https://gdihq.com/evaluate/register.php";
String method = params[0];
if(method.equals("Users")){
String Date = params[1];
String FirstName = params[2];
String LastName = params[3];
String Phone = params[4];
String Email = params[5];
try {
URL url = new URL(users_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream OS = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS,"UTF-8"));
String data = URLEncoder.encode("mDate","UTF-8") + "=" + URLEncoder.encode(Date,"UTF-8") + "&" +
URLEncoder.encode("FirstName","UTF-8") + "=" + URLEncoder.encode(FirstName,"UTF-8") + "&" +
URLEncoder.encode("LastName","UTF-8") + "=" + URLEncoder.encode(LastName,"UTF-8") + "&" +
URLEncoder.encode("Phone","UTF-8") + "=" + URLEncoder.encode(Phone,"UTF-8") + "&" +
URLEncoder.encode("Email","UTF-8") + "=" + URLEncoder.encode(Email,"UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
OS.close();
InputStream IS = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(IS,"iso-8859-1"));
String result = "";
String line = "";
while ((line = bufferedReader.readLine()) != null){
result += line;
}
bufferedReader.close();
IS.close();
httpURLConnection.disconnect();
return result;
} catch (MalformedURLException e) {
Log.d(TAG,"Stacktrace Malfunctioned Begins here");
Show(String.valueOf(e.getStackTrace()),ctx);
} catch (IOException e) {
Log.d(TAG,"Stacktrace Begins here");
e.printStackTrace();
}
}
return null;
下面是ioexception
java.io.FileNotFoundException: https://gdihq.com/evaluate/register.php
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:259)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at com.example.gdiapp.BackgroundTask.doInBackground(BackgroundTask.java:63)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at com.example.gdiapp.BackgroundTask.doInBackground(BackgroundTask.java:25)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at android.os.AsyncTask$3.call(AsyncTask.java:378)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2021-01-09 12:55:08.596 12651-31948/com.example.gdiapp W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
2021-01-09 12:55:08.597 12651-31948/com.example.gdiapp W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2021-01-09 12:55:08.597 12651-31948/com.example.gdiapp W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2021-01-09 12:55:08.597 12651-31948/com.example.gdiapp W/System.err: at java.lang.Thread.run(Thread.java:919)
但网站是正确的。我的错误是什么?
暂无答案!
目前还没有任何答案,快来回答吧!