【发布时间】:2014-05-20 03:58:20
【问题描述】:
我在 Java Swing 中创建了一个 JTable。
如何更新它以显示存储在我的 MySQL 数据库中的所有值?
我尝试在网上搜索,但仍然没有运气。
这是我的代码...
try{
PreparedStatement ps = con.prepareStatement("SELECT * FROM Users ");
ResultSet result = ps.executeQuery();
while(result.next()){
salesTable.setValueAt(result.getString("users"), 1, 1);
}
}
catch(SQLException sqle){
sqle.printStackTrace();
}
我不断收到java.lang.ArrayIndexOutOfBoundsException: 1 >= 0 错误。
如果有人能告诉我哪里出错并可能解决此错误,我将不胜感激。
【问题讨论】:
-
您在哪一行得到 ArrayIndexOutOfBoundsException。你可以添加堆栈跟踪吗?
标签: java mysql swing jtable indexoutofboundsexception