【问题标题】:java.lang.ArrayIndexOutOfBoundsException: 0 >= 0java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
【发布时间】:2013-07-17 12:45:27
【问题描述】:

这里是完整的代码:

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"};
}

【问题讨论】:

  • -1 表示错误的 codez 格式。
  • 错误代码格式的另一个-1
  • 您需要提供更多细节。您能否至少使用以下内容更新您的问题:1)Stacktrace 2)发生异常的代码。
  • 这个问题假设在无数错误代码中搜索错误。 SO 不是调试服务。
  • 我已经编辑过了。请帮我检查:

标签: java swing jtable abstracttablemodel


【解决方案1】:

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

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

请参阅Table From Database 中的Table From Database Example 代码,了解一个简单的示例,向您展示如何使用 DefaultTableModel。

【讨论】:

    猜你喜欢
    • 2014-01-30
    • 2014-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多