使用Echarts和Java Web技术实现可视化

在编写完项目时运行界面无法显示数据,求解答

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class NcovData {
    private int id;
    private int quantity;
    //private Date editDate;
    private String editDate;
    public NcovData() {}
    public NcovData(int id,int quantity,Date editDate) {
        this.id = id;
        this.quantity = quantity;
        try {
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            this.editDate = df.format(editDate);
        }catch(Exception e) {            
        }
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getQuantity() {
        return quantity;
    }
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }
    public String getEditDate() {
        return editDate;
    }
    public void setEditDate(String editDate) {
        this.editDate = editDate;
    }    
}
package dao;

import java.sql.ResultSet;

import util.DBBean;

public class DBTest {
    public static void main(String args[]) {
        new DBTest().test("ncov2020");
    }
    
    public void test(String tableName) {
        String sql = "select count(1) from "+tableName;
        DBBean bean = null;
        try {    
            bean = new DBBean();
            ResultSet rs = bean.executeQuery(sql, null);
            if(rs.next()) {
                int count = rs.getInt(1);
                System.out.print("表中记录数为:"+count);
            }            
        }catch(Exception e) {
            e.printStackTrace();
        }finally {
            bean.close();
        }
        
    }
}
package dao;

import java.util.Date;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import bean.NcovData;
import util.DBBean;

public class NcovDao {

    public static void main(String[] args) {
        List datas = new NcovDao().list();
        for(NcovData data:datas) {
            System.out.println(data.getId()+"\t"
                    +data.getQuantity()+"\t"+data.getEditDate());
            
    }
    }


public List list(){
    List datas = new ArrayList();
    String sql = "select * from ncov2020";
    DBBean bean = null;
    try {    
        bean = new DBBean();
        ResultSet rs = bean.executeQuery(sql, null);
        while(rs.next()) {
            int id = rs.getInt(1);
            int quantity = rs.getInt(2);
            Date editdate = rs.getDate(3);
            NcovData data = new NcovData(id,quantity,editdate);
            datas.add(data);
        }            
    }catch(Exception e) {
        e.printStackTrace();
    }finally {
        bean.close();
    }
    return datas;
}
}

import java.util.List;

import bean.NcovData;
import dao.NcovDao;

public class NcovService {
    NcovDao dao = new NcovDao();
    public List list(){
        return dao.list();
    }
}
package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import bean.NcovData;
import bean.Student;
import service.NcovService;

@WebServlet("/NcovServlet")
public class NcovServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        NcovService service = new NcovService();
        List datas = service.list();
        String info = JSON.toJSONString(datas);
        out.print(info);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}
package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class DBBean {
    private String url = "jdbc:mysql://localhost:3306/practice633?useSSL=false";  
    // 数据库信息,旧版本中不用useSSL=false
    private String username = "root";
    private String password = "123456";
    private String driverName = "com.mysql.jdbc.Driver";
    
    private Connection con=null;  //连接对象
    private PreparedStatement pstmt = null; //语句对象 
    private ResultSet rs = null; //结果集对象
    
    public DBBean() throws ClassNotFoundException, SQLException{
        Class.forName(driverName);
        con = DriverManager.getConnection(url,username,password);
    }
    
    /*
     * sql:要执行的SQL语句
     * params:SQL语句中需要的变量
     */
    public int executeUpdate(String sql,List params) throws SQLException{
        pstmt = con.prepareStatement(sql);
        if(params!=null && params.size()>0){
            for(int i=0;i1, params.get(i));
            }
        }
        return pstmt.executeUpdate();
    }
    
    public ResultSet executeQuery(String sql,List params) throws SQLException{
        pstmt = con.prepareStatement(sql);
        if(params!=null && params.size()>0){
            for(int i=0;i1, params.get(i));
            }
        }
        return pstmt.executeQuery();
    }
    
    public void close(){
        if(rs!=null){
            try{rs.close();}catch(Exception ee){}
        }
        if(pstmt!=null){
            try{pstmt.close();}catch(Exception ee){}
        }
        if(con!=null){
            try{con.close();}catch(Exception ee){}
        }
    }
}



以下是我的数据库截图以及项目截图:
理应显示出时间在界面上

img

img


请帮我解答

错误信息中,你这些都是信息,要找找错误和警告,上下滚动一下