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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i continue executing other SQL Statments , even if one of them fails
 
Similar Threads
Problem while executing Procedures Using Callable Statement
responce.sendRedirect()
how long execution plan for PreparedStatment live on Database
a.run() and a.start()
How to rollback multiple prepared statements