-4

这是完整的代码:

stat = con.prepareStatement("SELECT ExcelTable.PayorBankRoutNo, ExcelTable.Amount, ExcelTable.AccountNo, ExcelTable.SerialNo, ExcelTable.PresentingBankRoutNo, ExcelTable.PresentmentDate FROM ExcelTable WHERE ExcelTable.CreationDate = ? INNER JOIN (SELECT PayorBankRoutNo, Amount, AccountNo, SerialNo FROM ExcelTable GROUP BY PayorBankRoutNo, Amount, AccountNo, SerialNo HAVING (count(PayorBankRoutNo) > 1) AND (count(Amount) > 1) AND (count(AccountNo) > 1) AND (count(SerialNo) > 1)) dup ON ExcelTable.PayorBankRoutNo = dup.PayorBankRoutNo AND ExcelTable.Amount = dup.Amount AND ExcelTable.AccountNo = dup.AccountNo AND ExcelTable.SerialNo = dup.SerialNo ORDER BY ExcelTable.SerialNo");
            stat.setString(1, dateName);
            rs = stat.executeQuery();
            metadata = rs.getMetaData();
            li_cols = metadata.getColumnCount();
            allRows = new Vector();
            while(rs.next())
            {
                Vector newRow = new Vector();
                for(int i=1; i<= li_cols; i++)
                {
                    newRow.addElement(rs.getObject(i));
                }
                allRows.addElement(newRow);
            }fireTableStructureChanged(); 

        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.err.println("Error "+e);
        }
    }
    public int getColumnCount()
    {
        return li_cols;
    }
    public int getRowCount()
    {
        return allRows.size();
    }
    public Object getValueAt(int aRow, int aCol)
    {
        row = (Vector)allRows.elementAt(aRow);
        return row.elementAt(aCol);
    }
    public Class getColumnClass(int col)
    {
        return getValueAt(0, col).getClass();
    }
    public boolean isCellEditable(int row, int col)
    {
        return false;
    }
    public String getColumnName(int aCol)
    {
        return columnNames[aCol];
    }
    String[] columnNames = {"PAYORBANKROUTNO", "AMOUNT", "ACCOUNTNO", "SERIALNO", "PRESENTINGBANKROUTNO", "PRESENTMENTDATE"};
}
4

1 回答 1

0

你的问题可能无法回答。我们不知道错误发生在哪里或您的 TableModle 是什么样的。

为什么要创建自定义 TableModel?我猜这个问题是因为你错误地实现了模型。

有关向您展示如何使用 DefaultTableModel 的简单示例,请参阅数据库中的表Table From Database Example中的代码。

于 2013-07-17T14:42:44.263 回答