aspose file tools*
The moose likes JDBC and the fly likes How can i continue executing other SQL Statments , even if one of them fails Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How can i continue executing other SQL Statments , even if one of them fails " Watch "How can i continue executing other SQL Statments , even if one of them fails " New topic
Author

How can i continue executing other SQL Statments , even if one of them fails

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

I am executing , some sql statements , now the requirement is such that , even if a single statement execution fails ,i want to continue executng the others .

But right now the condition is such that , even if a single SQL Statement fails the execution is currently stopped at that Line .

Please let me know how can i continue executing the others even one statement fails .

Thanks



Save India From Corruption - Anna Hazare.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

We need to see your code.

The SQL won't stop - so it is in your JDBC code the change need to be made.


Regards, Rene Larsen
Dropbox Invite
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thanks for the response :

// Assume that the Table Users doesn't exists in the firsyt select query , so it will throw an Exception SQLException , i am handling that in my code, please tell me how can i make execute the next sequence of statements also


Any ideas
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

You need to take control over the Exceptions thrown from the stmt.executeQuery(..) by wrapping them into try/catch blocks.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you , what i am doing is that , for all the SQL Statements i am only using one Catch Exception block of SQLException , so in this case if one is failing the rest aren't being executed.

Anyway thanks for the help .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How can i continue executing other SQL Statments , even if one of them fails