要求开发一款移动端的全世界疫情实时查询系统。

要求将前两周的项目合并为一个完整的项目。

采用统一的数据库。(建议MySQL数据库)

实现从数据采集、数据存储、数据查询(WEB端和移动端)一体全世界实时疫情查询系统。

以本机数据库为服务器端,web端和移动端连接远程数据库实现数据共享,要求数据库表格式统一化。

查询显示当前最新时间的数据,可以查询任一时间任一地点的数据。该系统要求在服务器端发布,可以通过IP地址访问。

本次课结合了上上次课的web端和上次的数据爬取,结合三次课完成本次实验。

在实验过程中遇到了相当多的问题,比如如何从APP端获取Mysql数据,又比如获取的数据如何转化为可展示的数据

本次测试收获很多,在测试过程中,对app的开发有了妙不可言的看法,从确定焦点问题,到确定功能,再到数据获取,最后生成APP。行云流水。

但是遗憾的是我没有掌握如何对从web端获取的数据转换。

实验结果如下:

 

 

 

 

部分关键代码:


private void send() {
//开启线程,发送请求
new Thread(new Runnable() {
@Override
public void run() {
HttpURLConnection connection = null;
BufferedReader reader = null;
try {
EditText editText =(EditText)findViewById(R.id.editText);
String timeend = editText.getText().toString();
URL url = new URL("http://10.0.2.2:8080/ydyq/dengluServlet?timeend="+timeend);
//URL url = new URL("https://www.baidu.com/");
connection = (HttpURLConnection) url.openConnection();
//设置请求方法
connection.setRequestMethod("GET");
//设置连接超时时间(毫秒)
connection.setConnectTimeout(5000);
//设置读取超时时间(毫秒)
connection.setReadTimeout(5000);

//返回输入流
InputStream in = connection.getInputStream();

//读取输入流
reader = new BufferedReader(new InputStreamReader(in));
StringBuilder result = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
result.append(line);
}
show(result.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (connection != null) {//关闭连接
connection.disconnect();
}
}
}
}).start();
}