File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Slight JTable problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Slight JTable problem" Watch "Slight JTable problem" New topic

Slight JTable problem

Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
I have created a JTable and displayed the results of a SQL query. It compiles and runs fine but displays each recordSet 10 times. Can anyone see why this is happening?

[ February 13, 2004: Message edited by: Amy Phillips ]
Stuart Hoffman

Joined: Feb 13, 2004
Posts: 8
Amy, I'm a newbie but is it possible in this piece of the code that the for loop is executed too many times since it is inside of a while loop?
while({Object[] row = new Object[cols];for (int j = 0; j < row.length; j++){row[j] = rs.getObject(j + 1);cache.add(row);}}

Hope that helps
Amy Phillips
Ranch Hand

Joined: Apr 02, 2003
Posts: 280
Hi Stuart,
Thanks for your help, the problem was with the loop - I had the add(row) line inside the for loop so every line was being added 10 times.

btw - Welcome to the Java Ranch
I agree. Here's the link:
subject: Slight JTable problem
It's not a secret anymore!