过年前 问最后一个有关问题 关于SWING的jdbTable 怎么刷新数据 给大家拜年了

过年前 问最后一个问题 关于SWING的jdbTable 如何刷新数据给大家拜年了问题:jdbTable1每刷新一次自动把上

过年前 问最后一个问题 关于SWING的jdbTable 如何刷新数据 给大家拜年了
问题:jdbTable1每刷新一次   自动把上一次数据给加进来了   与预想不符
解决方法:先重写jdbTable1   然后刷仅刷新符合条件的数据   这里不知道该如何做?请大家帮帮忙
public   class   ScrapEquipmentSearch   extends   JFrame
{

    public   ScrapEquipmentSearch()
    {
        try   {
            jbInit();
        }
        catch   (Exception   ex)   {
            ex.printStackTrace();
        }

    }

    private   void   jbInit()   throws   Exception   {
.........
              database1.setConnection(new   ConnectionDescriptor( "jdbc:odbc:SDB ",   "sa ",
                "123 ",   false,   "sun.jdbc.odbc.JdbcOdbcDriver "));
        queryDataSet1.setReadOnly(true);
        queryDataSet1.setSort(new   com.borland.dx.dataset.SortDescriptor( " ",
                new   String[]   { "ID "},   new   boolean[]   {false,   },   null,   0));
        queryDataSet1.setStoreClassFactory(null);
        queryDataSet1.setAccumulateResults(true);
        queryDataSet1.setQuery(new   QueryDescriptor(database1,
                "Select   *   from   AppendEquipmentRegister     where   if_scrap   =1 ",   null,   true,
                                                                                          Load.ALL));
.............
              jdbTable1.setDataSet(queryDataSet1);
        tableScrollPane1.setBorder(BorderFactory.createEtchedBorder());
        tableScrollPane1.setDebugGraphicsOptions(0);
        jComboBox1.setForeground(Color.red);
        jButton3.setToolTipText( " ");
        jButton3.setText( "刷新 ");
        jButton3.addActionListener(new   ScrapEquipmentSearch_jButton3_actionAdapter(this));
        jComboBox2.setForeground(Color.red);
        jComboBox2.addItemListener(new   ScrapEquipmentSearch_jComboBox2_itemAdapter(this));
        jPanel1.add(jButton2,   new   XYConstraints(667,   6,   90,   37));
        jPanel1.add(jCheckBox1,   new   XYConstraints(443,   12,   -1,   -1));
        jPanel1.add(jButton1,   new   XYConstraints(562,   6,   90,   37));
        jPanel1.add(jLabel1,   new   XYConstraints(7,   15,   -1,   -1));
        this.getContentPane().add(tableScrollPane1,
                                                            new   XYConstraints(45,   89,   798,   351));


        tableScrollPane1.getViewport().add(jdbTable1);

        this.getContentPane().add(jPanel1,   new   XYConstraints(45,   4,   798,   56));
        jPanel1.add(jComboBox1,   new   XYConstraints(71,   11,   85,   -1));
        jPanel1.add(jButton3,   new   XYConstraints(163,   8,   84,   33));
        jPanel1.add(jComboBox2,   new   XYConstraints(312,   11,   111,   -1));
        jPanel1.add(jLabel2,   new   XYConstraints(274,   15,   -1,   -1));
        queryDataSet1.setColumns(new   Column[]   {column1,   column2,   column3,   column4,
                                                          column5,   column6,   column7,   column8,   column9,
                                                          column10,   column11,   column12,
                                                          column13,   column14,   column15});
    }

    XYLayout   xYLayout1   =   new   XYLayout();
    JPanel   jPanel1   =   new   JPanel();
    XYLayout   xYLayout2   =   new   XYLayout();
    JLabel   jLabel1   =   new   JLabel();
    JComboBox   jComboBox1   =   new   JComboBox();
    JLabel   jLabel2   =   new   JLabel();
    String   Selected1[]={ "按默认顺序 ", "按IP地址 ", "按购买时间 ", "按设备价值 ", "按设备类型 ", "按设备ID "};
    JComboBox   jComboBox2   =   new   JComboBox(Selected1);
    JCheckBox   jCheckBox1   =   new   JCheckBox();
    JButton   jButton1   =   new   JButton();
    JButton   jButton2   =   new   JButton();
    Database   database1   =   new   Database();
    QueryDataSet   queryDataSet1   =   new   QueryDataSet();
    Column   column1   =   new   Column();
    Column   column2   =   new   Column();
    Column   column3   =   new   Column();
    Column   column4   =   new   Column();
    Column   column5   =   new   Column();
    Column   column6   =   new   Column();
    Column   column7   =   new   Column();
    Column   column8   =   new   Column();
    Column   column9   =   new   Column();
    Column   column10   =   new   Column();
    Column   column11   =   new   Column();
    Column   column12   =   new   Column();
    Column   column13   =   new   Column();


    Column   column14   =   new   Column();
    Column   column15   =   new   Column();
    TableScrollPane   tableScrollPane1   =   new   TableScrollPane();
    JdbTable   jdbTable1   =   new   JdbTable();
    JButton   jButton3   =   new   JButton();
    public   void   this_windowOpened(WindowEvent   e)
    {
        String   ls_tmp;
        String   sql_basic;
        ResultSet   rs   =   null;
        PreparedStatement   stmt=   null;
        try
        {
              conn   =   DriverManager.getConnection( "jdbc:odbc:SDB ",   "sa ", "123 ");
              sql_basic= "select   DeptName   as   dept   from   Department ";
              stmt   =   conn.prepareStatement(sql_basic);
              rs=stmt.executeQuery();
              while   (rs.next())
              {
                  //将基础表department   中数据插入jComboBox1
                  ls_tmp   =   rs.getString( "dept ");
                  jComboBox1.addItem(ls_tmp);
              }
              stmt.close();
              conn.close();

        }
        catch   (Exception   ex)
        {
            ex.printStackTrace();
        }
    }

    public   void   jButton2_actionPerformed(ActionEvent   e)
    {
        //退出   返回上一界面
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);//默认点击关闭
        dispose();

    }

    public   void   jComboBox2_itemStateChanged(ItemEvent   e)
    {

    }

    public   void   jButton3_actionPerformed(ActionEvent   e)
    {

        PreparedStatement   stmt1   =   null;
        String   ls_dept   =   (String)jComboBox1.getSelectedItem();
        String   sql_dept   =   "select   *   from   AppendEquipmentRegister   where   dept   =   ' "+ls_dept+ " 'and   if_scrap   =1   ";
       
      try
        {
           
          conn1=   DriverManager.getConnection( "jdbc:odbc:SDB ",   "sa ", "123 ");
          stmt1   =   conn1.prepareStatement(sql_dept);


          stmt1.execute();
          this.jdbTable1.setModel(new   DefaultTableModel());//清空原有数据
          //想在jdbTable1中重新刷出符合条件的数据   请问该如何写?

          //queryDataSet1.refresh()   ;
         
        }
        catch   (Exception   ex)
        {
            ex.printStackTrace();
        }

    }
}
.........
}


[解决办法]
关注中,我也不会
[解决办法]
帮顶
[解决办法]
用Vector类的addElemets()的方法来添加表头和主体