Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SQLException in iteration and loop doesn't continue

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All
I have been stuck with this weird problem
In side a loop I have try catch block and for testing purpose I am explicitly throwing an SQLException on particular iteration and want the logic to continue the loop after recording the iteration no where Exception was thrown but It breaks out of the loop and comes in outer finally block
I am posting my code.If any one can give me an idea where I am wrong it will be of great help
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it has to do with the scope of the i variable which is for loop, not try block. So when i==4, it comes out of for loop. Instead of using try-catch block, other ways like printing messages when i==4 can be used, then continue the next loop. I hope this helps.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic