• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Slight JTable problem

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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?

Thanks
[ February 13, 2004: Message edited by: Amy Phillips ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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(rs.next()){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
Stuart
 
Amy Phillips
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic