• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

running a query within a loop. Need help

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

This is my first java ranch posting so please be kind... I have a problem, I'm creating a jsp running on tomcat, I�m trying to use a mysql db to create a page that shows what permissions different users for the application have.

SO... imaging a table where the headers going across are the names of the permissions and then the first column going down is a listing of all the usernames. And then on each row going across you have Xs or blanks telling you if a certain user has that certain right.

So at first thought this is easy. One query for your permissions, loop through that.... then a second query for your usernames, loop through that... now here is the problem. When you go through the LAST needed query, the one that will get the permissions based per user, the program crashes the entire jvm.

This is because new RS objects are being created on each iteration of the users (2nd) query.

My question? How can I do this without crashing my jvm?

Thanks,

Glenn
 
author & internet detective
Posts: 40747
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glenn,
Welcome to JavaRanch!

There isn't any inherent problem with what you are doing. It might perform slowly, but shouldn't cause the JVM to crash. (If you need it to work faster, you can look at joins or batching. If this is just to learn, it wouldn't matter.)

Are you closing all your resultset objects between queries? Also, if you aren't already, a PreparedStatement is better than a Statement since you are essentially doing the same query with different parameters.

For more specific help, feel free to post some code.
reply
    Bookmark Topic Watch Topic
  • New Topic