title: PreparedStatement in Java on a Fulltext MSSQL Table only takes 3 Arguments
body: <p>Strange behavior.</p>
  
  <p>We have the MSSQL server 2008 R2.</p>
  
  <p>Our Java Servlet is calling a PreparedStatement with the following join.</p>
  
  <pre><code>... inner join Containstable (fulltextTable, mycolumn, ?) as KeyTable on id = KeyTable.[KEY] ...
  </code></pre>
  
  <p>Where ? = needle</p>
  
  <p>This works fine.</p>
  
  <p>But when i add two more arguments to Containstable like this:</p>
  
  <pre><code>... inner join Containstable (fulltextTable, mycolumn, ?, ?, ?) as KeyTable on id = KeyTable.[KEY] ...
  </code></pre>
  
  <p>Where ? = needle (Search for), ? = LANGUAGE N'German' (Language), ? = 250 (Limit result to 250 rows)</p>
  
  <p>I get this exception:</p>
  
  <pre><code>java.sql.SQLException: Argument data type nvarchar is invalid for argument 4 of CONTAINSTABLE function.
  </code></pre>
  
  <p>This works fine in SQL Server Management Studio.</p>
  
  <p>Is this a Problem with the SQLServerDriver in Java? </p>
  
  <p>Cheers
  Per</p>
  
  <p>Here is my Code - this works:</p>
  
  <pre><code>if (contains!=null &amp;&amp; contains.length()!=0) {
      sql.append(" inner join Containstable( myFulltext, myColumn, ?) as KeyTable on id = KeyTable.[KEY]");
  
      elementTypes.add(Types.NVARCHAR);
      paramObject.add(contains);
      //elementTypes.add(Types.NVARCHAR);
      //paramObject.add("LANGUAGE N'German'");
      //elementTypes.add(Types.BIGINT);
      //paramObject.add(maxResults);              
  }
  </code></pre>