Dao层
package Dao; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; import DBUtil.DBUtil; import Bean.Diqu; import Bean.Sheng; public class Dao { public List<Diqu> tcha (String m,String n) { String sql="select * from diqu where 截止时间 like '%"+m+"%' and 地区 like '%"+n+"%'"; System.out.println(sql); Connection conn = DBUtil.getConn(); Statement state = null; ResultSet rs = null; List<Diqu> list = new ArrayList<>(); try { state = conn.createStatement(); rs = state.executeQuery(sql); Diqu bean = null; while (rs.next()) { String time = rs.getString("截止时间"); String diqu = rs.getString("地区"); String ill = rs.getString("确诊人数"); String newill=rs.getString("新增确诊"); String cure = rs.getString("治愈"); String dead = rs.getString("死亡"); bean=new Diqu(time,diqu,ill,newill,cure,dead); list.add(bean); } } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(state, conn); } return list; } public List<Sheng> Scha(String m) { String sql="select * from sheng where 截止时间 like '%"+m+"%'"; System.out.println(sql); Connection conn = DBUtil.getConn(); Statement state = null; ResultSet rs = null; List<Sheng> list = new ArrayList<>(); try { state = conn.createStatement(); rs = state.executeQuery(sql); while (rs.next()) { String time = rs.getString("截止时间"); String diqu = rs.getString("地区"); String person = rs.getString("确诊人数"); Sheng bean=new Sheng(time,diqu,person); list.add(bean); } System.out.println(list); } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(state, conn); } return list; } }