Welcome to MSDN Blogs Sign in | Join | Help

Microsoft JDBC Driver Team Blog

Discussions related to Microsoft JDBC driver.
Why doesn't executeUpdate() give me the exception I expected?

If you are using executeUpdate() to execute a query or stored procedure containing multiple SQL statements, the problem may just be that the error you're expecting wasn't the first result returned by the query.  Consider a case where you use executeUpdate() to call a stored procedure containing multiple SQL statements, and the first result is an update count (from INSERT, for example), followed later by some error.  Since executeUpdate() expects only a single update count, it returns the one for the INSERT statement as soon as it encounters it, leaving the error that follows it waiting to be retrieved.  If you want your application to “see” that error (thrown as exception by the driver) and any subsequent results, you need to call the stored procedure using execute() and process all of the results using getMoreResults().  See this post for details.

 

--David Olix [SQL Server]

This post is provided 'as is' and confers no express or implied warranties or rights.

Posted: Monday, August 04, 2008 3:32 PM by dpblogs
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker