title: com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter
body: <p>I get this exception sometimes only,like once in 100 calls. I looked for solutions but could not figure out. Stored procedure takes one input. The driver i use is sqljdbc4 version 4.0</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[PROC_CATEGORY_LIST] @USERID INT
  </code></pre>
  
  <p>and i have set the parameter as follows</p>
  
  <pre><code>    "EXEC PROC_CATEGORY_LIST ?"
      callableStatement.setInt(1, userId);
      resultSet = callableStatement.executeQuery();
  </code></pre>
  
  <p>I get the following exception</p>
  
  <pre><code>The value is not set for the parameter number 2.
  com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 2.
      at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildParamTypeDefinitions(SQLServerPreparedStatement.java:260)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildPreparedStrings(SQLServerPreparedStatement.java:219)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doPrepExec(SQLServerPreparedStatement.java:612)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:400)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
      at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)
      at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)
      at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180)
      at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155)
      at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285)
      at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementProxy.invoke(AbstractQueryReport.java:233)
      at com.sun.proxy.$Proxy2.executeQuery(Unknown Source)
  </code></pre>
  
  <p>Has anyone faced such problem. If yes what could be the possible solution.</p>