Error 4070 with Prepared Statements

I am writing a simple count(*) parameterized query, using placeholders (not numerical parameters).

If I use the default N1qlParams, the query succeeds and returns the appropriate value.

If i set adhoc to false, then I get the following error:

{“msg”:“Unable to decode prepared statement - cause: Unrecognizable prepared statement - cause: unable to convert to prepared statment.”,“code”:4070}

What could be causing this? (I am using version 2.2.3 of the java sdk)

I think @simonbasle or @daschl can help you on that one.

Are you using Couchbase 4.0 or Couchbase 4.1?
I know there was a known bug with prepared statements and aggregations (like count, sum, etc…) in 4.0, on the server side.
If you can’t make the server upgrade, you’ll have to refrain from using prepared statements for these kind of queries I’m afraid.

Ah yes I am using 4.0, thanks for the information.

We will upgrade when we get the chance and in the meantime, leave that optimization off for aggregation queries.