wood burning stoves 2.0*
The moose likes JDBC and the fly likes SQLException in iteration and loop doesn't continue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException in iteration and loop doesn Watch "SQLException in iteration and loop doesn New topic
Author

SQLException in iteration and loop doesn't continue

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
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


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Suman Sharma
Ranch Hand

Joined: May 16, 2005
Posts: 72
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException in iteration and loop doesn't continue
 
Similar Threads
connection rollback/ atomic transaction problem
How to do sorting with mysql?
howto modify database structure ?
insert null date into DB2 using preparestatement
maximum open cursors exceeded