JAVA How to JAVA Development tutorials and how to

20Jul/100

How to set ARITHABORT from JAVA – SQL Server

I had a problem yesterday. I was developing a RESTful web service where i have to run an UPDATE to SQL Server 2005 table, but when i do that i have the next problem:

UPDATE failed because the following SET options have incorrect settings: 'ARIHABORT'

Damn! What the hell is that? Googling i found this:

http://j2eeframeworks.blogspot.com/2008/10/insert-failed-because-following-set.html

And i understood that the table that i want to update is related to indexed views so the UPDATE or INSERT proccess isn't as simple because i had to set the parameter ARIHABORT = ON to do my operations.

So, how to do that? Whe need to execute the next statement:

SET ARIHABORT ON;

From JAVA. As you can see in the link, the guy recommends to execute the statement using Statement object, like the next code:

 Connection sqlsConn = myManager.getSQLSConnection();
 Statement stmt = sqlsConn.createStatement();
 stmt.execute("SET ARITHABORT ON");

And that's it!! :D . An important advice is that, if you use PreparedStatement or something like that, it doesn't work!! I throws an exception.

Share and Enjoy

  • Twitter
  • Facebook
  • Digg
  • del.icio.us
  • Technorati
  • MySpace
  • Sphinn
  • Print
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Identi.ca
  • LinkedIn
  • Meneame
  • Netvibes
  • Yigg
  • Reddit
  • RSS
  • Tumblr
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.