Hi, I'm trying to use bounded query and I get  weird error:

Here is a query:

Bounded query: INSERT INTO packets (id, fingerprint, mark) VALUES (?, ?, ?);


Here is a code:

PreparedStatement preparedStatement = session.prepare(composeQuery());
//composeQuery returns INSERT INTO packets (id, fingerprint, mark) VALUES
(?, ?, ?);

BoundStatement boundStatement = new BoundStatement(preparedStatement);
//EXCEPTION HERE

boundStatement.bind(UUID.randomUUID(), RandomStringUtils.random(10), 1);

session.execute(boundStatement);
If I use cqlsh and run

INSERT INTO packets (id, fingerprint, mark) VALUES (now(), 'xxx', 1);
it works

Stacktrace:

Exception in thread "main" com.datastax.driver.core.exceptions.SyntaxError:
line 1:37 no viable alternative at character ' '

at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:35)

at
com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:289)

at com.datastax.driver.core.AbstractSession.prepare(AbstractSession.java:79)

at stress.StressTest.runBound(StressTest.java:89)

at stress.Main.main(Main.java:29)

Caused by: com.datastax.driver.core.exceptions.SyntaxError: line 1:37 no
viable alternative at character ' '

at com.datastax.driver.core.Responses$Error.asException(Responses.java:101)

at com.datastax.driver.core.SessionManager$1.apply(SessionManager.java:185)

at com.datastax.driver.core.SessionManager$1.apply(SessionManager.java:160)

at com.google.common.util.concurrent.Futures$1.apply(Futures.java:720)

at
com.google.common.util.concurrent.Futures$ChainingListenableFuture.run(Futures.java:859)

at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

 at java.lang.Thread.run(Thread.java:745)

Reply via email to