实验二 代码补充

Posted 1556889081wyq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验二 代码补充相关的知识,希望对你有一定的参考价值。

package xxxgai;

import java.awt.Font;
import java.awt.GridLayout;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

import javax.swing.JFrame;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;

public class TestFly {

static Connection con = null;//连接
static PreparedStatement ps = null;//模板
static ResultSet rs = null;//结果集
//柱状图生成部分
static ChartPanel frame1;
private static int a=0;

public static void main(String[] args) throws Exception {      
    System.out.println("******************************************防疫信息管理系统********************************************
");
    //show();
    boolean bool = Dome();
    while(bool){
        bool = Dome();
    }
    if(!bool){
        System.out.println("**************************************已成功退出防疫信息管理系统**************************************
");
        System.exit(0);
    }
}

//流程
public static boolean Dome() throws Exception{
    Scanner scan = new Scanner(System.in);
    show();
    int key = scan.nextInt();
    switch (key) {
    case 1:
        showMessage(listMessage());
        break;
        
    case 2:{
        System.out.println("输入时间:");
        String date = scan.next();
        showMessage(selectDate(date));
        System.out.println("在"+date+"参与统计的人数
");
        showNum(selectDate(date));
    }break;
    
    case 3:{
        System.out.println("输入想查询的防疫信息:"请选择操作:(1.有无发热,2.是否为留校学生,3.是否为湖北籍,4.是否与武汉疫区人员接触,5.是否与湖北疫区人员接触,6.是否在武汉,7.是否在湖北,8.今天从外地返校)");
        int key1 = scan.nextInt();
        switch (key1) {
        case 1:{
            System.out.println("有无发热:");
            String Situation = scan.next();
            showMessage(selectSituation(Situation));
            if(Situation.equals("有发热")) {
                System.out.println("发热人数为:");
            }
            else if(Situation.equals("无发热")) {
                System.out.println("未发热人数为:");
            }
            a=showNum(selectSituation(Situation));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 2:{
            System.out.println("是否为留校学生:");
            String Situation1 = scan.next();
            showMessage(selectSituation1(Situation1));
            if(Situation1.equals("是")) {
                System.out.println("是留校学生的人数为:");
            }
            else if(Situation1.equals("否")) {
                System.out.println("不是留校学生人数为:");
            }
            a=showNum(selectSituation1(Situation1));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 3:{
            System.out.println("是否为湖北籍:");
            String Situation2 = scan.next();
            showMessage(selectSituation2(Situation2));
            if(Situation2.equals("是")) {
                System.out.println("湖北籍人数为:");
            }
            else if(Situation2.equals("否")) {
                System.out.println("湖北籍人数为:");
            }
            a=showNum(selectSituation2(Situation2));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 4:{
            System.out.println("是否与武汉疫区人员接触: ");
            String Situation3 = scan.next();
            showMessage(selectSituation3(Situation3));
            if(Situation3.equals("是")) {
                System.out.println("已经与武汉疫区人员接触的人数为:");
            }
            else if(Situation3.equals("否")) {
                System.out.println("未与武汉疫区人员接触的人数为:");
            }
            a=showNum(selectSituation3(Situation3));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 5:{
            System.out.println("是否与湖北疫区人员接触:");
            String Situation4 = scan.next();
            showMessage(selectSituation4(Situation4));
            if(Situation4.equals("是")) {
                System.out.println("已经与湖北疫区人员接触的人数为:");
            }
            else if(Situation4.equals("否")) {
                System.out.println("未与湖北疫区人员接触的人数为:");
            }
            a=showNum(selectSituation4(Situation4));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 6:{
            System.out.println("是否在武汉:");
            String Situation5 = scan.next();
            showMessage(selectSituation5(Situation5));
            if(Situation5.equals("是")) {
                System.out.println("在武汉的人数为:");
            }
            else if(Situation5.equals("否")) {
                System.out.println("未在武汉的人数为:");
            }
            a=showNum(selectSituation5(Situation5));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 7:{
            System.out.println("是否在湖北:");
            String Situation6 = scan.next();
            showMessage(selectSituation6(Situation6));
            if(Situation6.equals("是")) {
                System.out.println("在湖北的人数为:");
            }
            else if(Situation6.equals("否")) {
                System.out.println("未在湖北的人数为:");
            }
            a=showNum(selectSituation6(Situation6));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
        case 8:{
            System.out.println("是否今天从外地返校:");
            String Situation7 = scan.next();
            showMessage(selectSituation7(Situation7));
            if(Situation7.equals("是")) {
                System.out.println("返校人数为:");
            }
            else if(Situation7.equals("否")) {
                System.out.println("未返校人数为:");
            }
            a=showNum(selectSituation7(Situation7));
            //生成柱状图
            System.out.println("******");
            System.out.println("是否要生成柱状图:");
            String b = scan.next();
            System.out.println("******");
            if(b.equals("是")) {
                TestFly();
                JFrame frame=new JFrame("该数据的数量统计");
                   frame.setLayout(new GridLayout(2,2,5,5));
                   frame.add(new TestFly().getChartPanel());   //添加柱形图
                   frame.setBounds(0, 0, 600, 500);
                   frame.setVisible(true);
            }
            else if(b.equals("否")) {
                System.out.println("******");
                System.out.println("退出中");
                System.out.println("******");
            }
        }break;
    }           
    }break;
    
    case 4:{
        System.out.println("输入姓名(学号):");
        String name = scan.next();
        selectAntiNum(name);
    }break;
    
    case 5:{
        System.out.println("输入姓名(学号)和日期,进行准确查询:");
        String name = scan.next();
        String date = scan.next();
        selectAntiNum1(name,date);
    }break;
    
    case 6:{
        System.out.println("输入姓名(学号):");
        String name = scan.next();
        deleteFly(name);
    }break;
                    
    case 7:{
        System.out.println("输入姓名(学号)、发热情况、登记时间、疫情情况:");
        String name = scan.next();
        String Situation = scan.next();
        String Situation1 = scan.next();
        String Situation2 = scan.next();
        String Situation3 = scan.next();
        String Situation4 = scan.next();
        String Situation5 = scan.next();
        String Situation6 = scan.next();
        String Situation7 = scan.next();
        String date = scan.next();
        creatAnti(name,Situation,Situation1,Situation2,Situation3,Situation4,Situation5,Situation6,Situation7,date);
    }break;
                    
    default:
        //scan.close();
        return false;
    }
    //scan.close();
    return true;
}
//生成柱状图
private static void TestFly() {
    CategoryDataset dataset = getDataSet();//将获得的数据传递给CategoryDataset类的对象
       JFreeChart chart = ChartFactory.createBarChart3D(
                             "人数统计表", // 图表标题
                           "人数信息", // 目录轴的显示标签
                           "人数/个", // 数值轴的显示标签
                           dataset, // 数据集
                           PlotOrientation.VERTICAL, // 图表方向:水平、垂直
                           true, // 是否显示图例(对于简单的柱状图必须是false)
                           false,  // 是否生成工具
                           false  // 是否生成URL链接
                           );
      
       CategoryPlot plot=chart.getCategoryPlot();//获取图表区域对象
       CategoryAxis domainAxis=plot.getDomainAxis();         //水平底部列表
        domainAxis.setLabelFont(new Font("黑体",Font.BOLD,14));         //水平底部标题
        domainAxis.setTickLabelFont(new Font("宋体",Font.BOLD,12));  //垂直标题
        ValueAxis rangeAxis=plot.getRangeAxis();//获取柱状
        rangeAxis.setLabelFont(new Font("黑体",Font.BOLD,15));
         chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
         chart.getTitle().setFont(new Font("宋体",Font.BOLD,20));//设置标题字体

        frame1=new ChartPanel(chart,true);  //这里也可以用chartFrame,可以直接生成一个独立的Frame
        
    }   
       private static CategoryDataset getDataSet() {
          DefaultCategoryDataset dataset = new DefaultCategoryDataset();
          dataset.addValue(a,"situation", "situation");//成绩1
          return dataset;
       }
       public ChartPanel getChartPanel(){
           return frame1;
    
        }
//注册驱动,获取连接
public static Connection getCon() throws Exception{
    Class.forName("com.mysql.jdbc.Driver");
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/fly", "root", "19981228");
    return con;
}

//创建初始信息,插入信息
public static void creatAnti(String name,String situation, String situation1, String situation2, String situation3, String situation4, String situation5, String situation6, String situation7,String date) throws Exception{
    getCon();
    String sql = "insert into anti values (null,?,?,?,?,?,?,?,?,?,?)";
    ps = con.prepareStatement(sql);
    ps.setString(1, name);
    ps.setString(2, situation);
    ps.setString(3, situation1);
    ps.setString(4, situation2);
    ps.setString(5, situation3);
    ps.setString(6, situation4);
    ps.setString(7, situation5);
    ps.setString(8, situation6);
    ps.setString(9, situation7);
    ps.setString(10, date);
    ps.executeUpdate();
    ps.close();
    con.close();
    selectAntiNum(name);
}

//系统主菜单
public static void show(){
    System.out.println("请选择操作:(1.列出防疫信息,2.按时间查询,3.按防疫信息查询,4.按姓名(学号)查询,5.按姓名(学号)查询和日期,进行准确查询,6.删除人员信息,7.添加人员信息, 8.退出系統)");
}

//获取结果集合输出
public static void showMessage(Set<Anti> set){
    System.out.println("
********************************版权所有:wyq***********************************
");
    if(set.size() == 0){
        System.out.println("未匹配到任何数据!");
        System.out.println("
********************************版权所有:wyq***********************************
");
        return;
    }
    System.out.println("Anti		姓名		有无发热		是否为留校学生/是否为湖北籍/是否与武汉疫区人员接触/是否与湖北疫区人员接触/是否在武汉	是否在湖北	是否今天从外地返校 时间");
    for( Anti value : set){
        System.out.println(value);
    }
    System.out.println("
********************************版权所有:wyq***********************************
");
}
//获取此数据的人数
public static int showNum(Set<Anti> set){
    int x=0;
    for( Anti value : set){
        x++;
        System.out.println(value);
    }
    System.out.println("
***数据统计***
");
    System.out.println("共有"+x+"人");
    System.out.println("
***数据统计***
");
    return x;
}   
//列出防疫信息
public static Set<Anti> listMessage() throws Exception{
    getCon();
    String sql = "select * from anti";
    ps = con.prepareStatement(sql);
    rs = ps.executeQuery();
    
    Set<Anti> set = new HashSet<>();
    
    while(rs.next()){
        int id = rs.getInt("id");
        String name = rs.getString("name");
        String situation = rs.getString("situation");
        String situation1 = rs.getString("situation1");
        String situation2 = rs.getString("situation2");
        String situation3 = rs.getString("situation3");
        String situation4 = rs.getString("situation4");
        String situation5 = rs.getString("situation5");
        String situation6 = rs.getString("situation6");
        String situation7 = rs.getString("situation7");
        String dateTime = rs.getString("date");
        Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
        set.add(anti);
    }
    ps.close();
    con.close();
    return set;
}

//按时间
public static Set<Anti> selectDate(String date) throws Exception{
    getCon();
    String sql = "select * from anti where date = ? ";
    ps = con.prepareStatement(sql);
    ps.setString(1, date);
    rs = ps.executeQuery();
    
    Set<Anti> set = new HashSet<>();

    while(rs.next()){
        int id = rs.getInt("id");
        String name = rs.getString("name");
        String situation = rs.getString("situation");
        String situation1 = rs.getString("situation1");
        String situation2 = rs.getString("situation2");
        String situation3 = rs.getString("situation3");
        String situation4 = rs.getString("situation4");
        String situation5 = rs.getString("situation5");
        String situation6 = rs.getString("situation6");
        String situation7 = rs.getString("situation7");
        String dateTime = rs.getString("date");
        Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
        set.add(anti);
    }
    ps.close();
    con.close();
    return set;
}

//按防疫情况
public static Set<Anti> selectSituation(String Situation) throws Exception{
    getCon();
    String sql = "select * from anti where situation = ? ";
    ps = con.prepareStatement(sql);
    ps.setString(1, Situation);
    rs = ps.executeQuery();
    
    Set<Anti> set = new HashSet<>();
    
    while(rs.next()){
        int id = rs.getInt("id");
        String name = rs.getString("name");
        String situation = rs.getString("situation");
        String situation1 = rs.getString("situation1");
        String situation2 = rs.getString("situation2");
        String situation3 = rs.getString("situation3");
        String situation4 = rs.getString("situation4");
        String situation5 = rs.getString("situation5");
        String situation6 = rs.getString("situation6");
        String situation7 = rs.getString("situation7");
        String dateTime = rs.getString("date");
        Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
        set.add(anti);
    }
    ps.close();
    con.close();
    return set;
}
    //按防疫情况1
    public static Set<Anti> selectSituation1(String Situation1) throws Exception{
        getCon();
        String sql = "select * from anti where situation1 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation1);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况2
    public static Set<Anti> selectSituation2(String Situation2) throws Exception{
        getCon();
        String sql = "select * from anti where situation2 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation2);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况3
    public static Set<Anti> selectSituation3(String Situation3) throws Exception{
        getCon();
        String sql = "select * from anti where situation3 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(4, Situation3);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况4
    public static Set<Anti> selectSituation4(String Situation4) throws Exception{
        getCon();
        String sql = "select * from anti where situation4 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation4);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况
    public static Set<Anti> selectSituation5(String Situation5) throws Exception{
        getCon();
        String sql = "select * from anti where situation5 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation5);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况6
    public static Set<Anti> selectSituation6(String Situation6) throws Exception{
        getCon();
        String sql = "select * from anti where situation6 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation6);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }
    //按防疫情况7
    public static Set<Anti> selectSituation7(String Situation7) throws Exception{
        getCon();
        String sql = "select * from anti where situation7 = ? ";
        ps = con.prepareStatement(sql);
        ps.setString(1, Situation7);
        rs = ps.executeQuery();
        
        Set<Anti> set = new HashSet<>();
        
        while(rs.next()){
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String situation = rs.getString("situation");
            String situation1 = rs.getString("situation1");
            String situation2 = rs.getString("situation2");
            String situation3 = rs.getString("situation3");
            String situation4 = rs.getString("situation4");
            String situation5 = rs.getString("situation5");
            String situation6 = rs.getString("situation6");
            String situation7 = rs.getString("situation7");
            String dateTime = rs.getString("date");
            Anti anti = new Anti(id, name, situation, situation1, situation2, situation3, situation4, situation5, situation6, situation7,dateTime);
            set.add(anti);
        }
        ps.close();
        con.close();
        return set;
    }   
//按姓名
public static void selectAntiNum(String name) throws Exception{
    getCon();
    String sql = "select * from anti where name = ? ";
    ps = con.prepareStatement(sql);
    ps.setString(1, name);
    rs = ps.executeQuery();
    boolean x = true;
    while(rs.next()){
        if(x){
            System.out.println("
********************************版权所有:wyq***********************************
");
        }
        int id = rs.getInt("id");
        String antinum = rs.getString("name");
        String situation = rs.getString("situation");
        String situation1 = rs.getString("situation1");
        String situation2 = rs.getString("situation2");
        String situation3 = rs.getString("situation3");
        String situation4 = rs.getString("situation4");
        String situation5 = rs.getString("situation5");
        String situation6 = rs.getString("situation6");
        String situation7 = rs.getString("situation7");
        String date = rs.getString("date");
        System.out.println("Anti" + id + "		" + antinum + "		" + situation + "		" + situation1 + "		" + situation2 + "		" + situation3 + "		" + situation4 +  "		" + situation5 + "		" + situation6 + "		" + situation7 + "		" + date);
        x = false;
    }
    System.out.println("
********************************版权所有:wyq***********************************
");
}

public static void selectAntiNum1(String name,String date) throws Exception{
    getCon();
    String sql = "select * from anti where name = ? and date = ? ";
    ps = con.prepareStatement(sql);
    ps.setString(1, name);
    ps.setString(2, date);
    rs = ps.executeQuery();
    boolean x = true;
    while(rs.next()){
        if(x){
            System.out.println("
********************************版权所有:wyq***********************************
");
        }
        int id = rs.getInt("id");
        String antinum = rs.getString("name");
        String situation = rs.getString("situation");
        String situation1 = rs.getString("situation1");
        String situation2 = rs.getString("situation2");
        String situation3 = rs.getString("situation3");
        String situation4 = rs.getString("situation4");
        String situation5 = rs.getString("situation5");
        String situation6 = rs.getString("situation6");
        String situation7 = rs.getString("situation7");
        String date1 = rs.getString("date");
        System.out.println("Anti" + id + "		" + antinum + "		" + situation + "		" + situation1 + "		" + situation2 + "		" + situation3 + "		" + situation4 +  "		" + situation5 + "		" + situation6 + "		" + situation7 + "		" + date);
        x = false;
    }
    System.out.println("
********************************版权所有:wyq***********************************
");
}

//按姓名删除防疫信息
public static void deleteFly(String name) throws Exception{
    getCon();
    String sql = "delete from anti where name = ? ";
    ps = con.prepareStatement(sql);
    ps.setString(1, name);
    ps.executeUpdate();
    ps.close();
    con.close();
    System.out.println("
********************************版权所有:wyq***********************************
");
    System.out.println("已删除!");
    System.out.println("
********************************版权所有:wyq***********************************
");
}

}

引用到的库:
技术图片

以上是关于实验二 代码补充的主要内容,如果未能解决你的问题,请参考以下文章

深度学习实战——不同方式的模型部署(CNNYolo)

vs 2010代码片段

vs 2010代码片段

js常用代码片段

201555332盛照宗—网络对抗实验1—逆向与bof基础

Bomblab