I am getting an exception when doing a batch insert operation using a prepared statement from Java.
java.sql.BatchUpdateException: The prepared statement handle 5 is not valid in this context. Please verify that current database, user default schema, and ANSI_NULLS and QUOTED_IDENTIFIER set options are not changed since the handle is prepared.
While analyzing this error message all I could find out was its error message id : 586. I could not gather any more information about this issue.
Can anyone help me with the reason for this exception, what it means and how to resolve it ?
Machine Details :
SQL Server Version - SQL Server 2014
jTDS JAR Version - 1.2.4
PS : This exception only occurs on a particular remote machine. We cant reproduce this issue locally. Any tips on how to reproduce this issue would also be helpful.
-
When you talk about remote machine, do you mean you are connecting from machine A and inserting into machine B?John K. N.– John K. N.2017年02月07日 08:35:49 +00:00Commented Feb 7, 2017 at 8:35
-
I mean, the setup is present on a machine which I don't have access to. But as you said, my application is running on machine-a connecting to SQL Server on machine-b.suraj1291993– suraj12919932017年02月07日 09:36:25 +00:00Commented Feb 7, 2017 at 9:36
-
1I'm totally guessing here, but is it possible your app//framework uses connection pooling and doesn't correctly reset the connection on reuse? That could possibly explain the unexpected set options found.T.H.– T.H.2017年02月07日 09:52:29 +00:00Commented Feb 7, 2017 at 9:52
-
Can you post the sql command?McNets– McNets2017年02月07日 11:50:46 +00:00Commented Feb 7, 2017 at 11:50
-
@McNets We are inserting bulk of rows over different tables using multiple prepared statement. I exactly dont know over what table I am getting this exception.suraj1291993– suraj12919932017年02月07日 13:43:04 +00:00Commented Feb 7, 2017 at 13:43
1 Answer 1
It seems that this server has been configured in a different way than the others.
Using SSMS, right click over server instance in some of the servers where the job is running and check that ANSI NULLS
and quoted identifier
have the same value on this server.
If you prefer to use an script, have a look at:
Explore related questions
See similar questions with these tags.