使用jframe操作数据库数据,一定要先创建对象类,使用集合操作吗

做一个简易的用户管理系统,实现增删改查功能

两个jframe间的数据传输怎么实现?
没有对象类

img

jtable呈现代码

all.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String sql = "select num as 序号  ,date as 日期 ,name as 姓名,phone as 手机号,sex as 性别  ,age as 年龄 ,history as 病例    from vip";
                DUBtil db = new DUBtil();
                try {
                    db.getConnection();
                    ResultSet rs = db.executeQuery(sql, null);
                    ResultSetMetaData rsmd = rs.getMetaData();
                    // 获取列数
                    int colCount = rsmd.getColumnCount();
                    // 存放列名
                    Vector<String> title = new Vector<String>();
                    // 列名
                    
                    for (int i = 1; i <= colCount; i++) {
                        title.add(rsmd.getColumnLabel(i));
                        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//                        fitTableColumns(table);
                        
                    }
        
                    // 表格数据
                    Vector<Vector<String>> data = new Vector<Vector<String>>();
                    int rowCount = 0;
                    while (rs.next()) {
                        rowCount++;
                        // 行数据
                        Vector<String> rowdata = new Vector<String>();
                        for (int i = 1; i <= colCount; i++) {
                            rowdata.add(rs.getString(i));
                        }
                        data.add(rowdata);
                    }
                    if (rowCount == 0) {
                        model.setDataVector(null, title);
                    } else {
                        model.setDataVector(data, title);
                        
                    }
        
        
                } catch (Exception ee) {
                    System.out.println(ee.toString());
                    JOptionPane.showMessageDialog(JF, "【系统异常!】", "失败",0);
                } finally {
                    db.closeAll();
                }
            }
        });

新建功能的代码该怎么完成?

btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
//                int row = main.table.getSelectedRow();
////                String oid = (String)dtm.getValueAt(row, 0);
//                String name = (String)namet.getValueAt(row, 1);
//                String phone = (String)dtm.getValueAt(row, 2);
//                String sex = (String)dtm.getValueAt(row, 3);
//                String age = (String)dtm.getValueAt(row, 3);
//                String history = (String)dtm.getValueAt(row, 3);
//                String str = sd.Insert(oid, oname, ocourse, odegree);
//                JOptionPane.showMessageDialog(null, str);

            }
        });

已经完成了

    public void actionPerformed(ActionEvent e) {
                DUBtil db=new DUBtil();
                Connection conn=null;
                try {
                    conn=db.getConnection();
                    Statement stmt=conn.createStatement();
                    String name = namet.getText() ;
                    System.out.print(name);
                    String phone =phonet.getText();
                    System.out.print(phone);
                    String sex="男";
                    System.out.print(sex);                
                    String age =aget.getText() ;
                    System.out.print(age);
                    String history =historyt.getText();
                    System.out.print(history);
                    String pricet =price.getText();
                    System.out.print(pricet);
                    LocalDate date = LocalDate.now();
                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");  
                    System.out.println(date.format(formatter)); 
                    String time=date.format(formatter);
                    
                    String str="insert into vip(date, name, phone, sex, age, price, history ) values ('"+time+"','"+name+"','"+phone+"','"+sex+"','"+age+"','"+pricet+"','"+history+"')";
                  
                    db.executeUpdate(str,null);
                    JOptionPane.showMessageDialog(JF2, "【添加成功!!!】", "成功",1);
                    
                }
                 catch (Exception ee) {
                    JOptionPane.showMessageDialog(JF2, "【系统异常!】", "失败",0);
                } finally {
                    db.closeAll();
                    dispose();
                }
                
            }